<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<HTML>
<HEAD>
<LINK REL=STYLESHEET TYPE="text/css" HREF="../stylesheet.css" TITLE="Style">
<META NAME="GENERATOR" CONTENT="Java2HTML Version 1.5">
<TITLE>jminusminus.CLEmitter (Java2HTML)</TITLE>
</HEAD>
<BODY><TABLE id="Header" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td colspan="2" width="33%">&nbsp;</td>
<td align="center" colspan="2" width="33%">
<font size="4">CLEmitter.java</font>
</td>
<td align="right" colspan="2" width="33%">&nbsp;</td>
</tr>
</TABLE>
<pre ID="Classes">
<FONT ID="LN">1   </FONT><A NAME="1"></A><FONT ID="SingleLineComment">// Copyright 2013 Bill Campbell, Swami Iyer and Bahar Akbal-Delibas
<FONT ID="LN">2   </FONT><A NAME="2"></A></FONT>
<FONT ID="LN">3   </FONT><A NAME="3"></A><FONT ID="Package">package</FONT> jminusminus;
<FONT ID="LN">4   </FONT><A NAME="4"></A>
<FONT ID="LN">5   </FONT><A NAME="5"></A><FONT ID="Import">import</FONT> java.io.BufferedOutputStream;
<FONT ID="LN">6   </FONT><A NAME="6"></A><FONT ID="Import">import</FONT> java.io.ByteArrayOutputStream;
<FONT ID="LN">7   </FONT><A NAME="7"></A><FONT ID="Import">import</FONT> java.io.File;
<FONT ID="LN">8   </FONT><A NAME="8"></A><FONT ID="Import">import</FONT> java.io.FileNotFoundException;
<FONT ID="LN">9   </FONT><A NAME="9"></A><FONT ID="Import">import</FONT> java.io.FileOutputStream;
<FONT ID="LN">10  </FONT><A NAME="10"></A><FONT ID="Import">import</FONT> java.io.IOException;
<FONT ID="LN">11  </FONT><A NAME="11"></A><FONT ID="Import">import</FONT> java.io.DataOutputStream;
<FONT ID="LN">12  </FONT><A NAME="12"></A><FONT ID="Import">import</FONT> java.io.OutputStream;
<FONT ID="LN">13  </FONT><A NAME="13"></A><FONT ID="Import">import</FONT> java.util.ArrayList;
<FONT ID="LN">14  </FONT><A NAME="14"></A><FONT ID="Import">import</FONT> java.util.Hashtable;
<FONT ID="LN">15  </FONT><A NAME="15"></A><FONT ID="Import">import</FONT> java.util.Stack;
<FONT ID="LN">16  </FONT><A NAME="16"></A><FONT ID="Import">import</FONT> java.util.StringTokenizer;
<FONT ID="LN">17  </FONT><A NAME="17"></A><FONT ID="Import">import</FONT> java.util.TreeMap;
<FONT ID="LN">18  </FONT><A NAME="18"></A><FONT ID="Import">import</FONT> <FONT ID="Static">static</FONT> <A HREF="../jminusminus/CLConstants.java.html">jminusminus.CLConstants</A>.*;
<FONT ID="LN">19  </FONT><A NAME="19"></A><FONT ID="Import">import</FONT> <FONT ID="Static">static</FONT> <A HREF="../jminusminus/CLConstants.java.html">jminusminus.CLConstants.Category</A>.*;
<FONT ID="LN">20  </FONT><A NAME="20"></A>
<FONT ID="LN">21  </FONT><A NAME="21"></A><FONT ID="FormalComment">/**
<FONT ID="LN">22  </FONT><A NAME="22"></A> * This class provides a high level interface for creating (in-memory and file
<FONT ID="LN">23  </FONT><A NAME="23"></A> * based) representation of Java classes.
<FONT ID="LN">24  </FONT><A NAME="24"></A> * 
<FONT ID="LN">25  </FONT><A NAME="25"></A> * j-- uses this interface to produce target JVM bytecode from a j-- source
<FONT ID="LN">26  </FONT><A NAME="26"></A> * program. During the pre-analysis and analysis phases, j-- produces partial
<FONT ID="LN">27  </FONT><A NAME="27"></A> * (in-memory) classes for the type declarations within the compilation unit,
<FONT ID="LN">28  </FONT><A NAME="28"></A> * and during the code generation phase, it produces file-based classes for the
<FONT ID="LN">29  </FONT><A NAME="29"></A> * declarations.
<FONT ID="LN">30  </FONT><A NAME="30"></A> */</FONT>
<FONT ID="LN">31  </FONT><A NAME="31"></A>
<FONT ID="LN">32  </FONT><A NAME="32"></A><FONT ID="Public">public</FONT> <FONT ID="Class">class</FONT> CLEmitter {
<FONT ID="LN">33  </FONT><A NAME="33"></A>
<FONT ID="LN">34  </FONT><A NAME="34"></A>    <FONT ID="FormalComment">/** Name of the class. */</FONT>
<FONT ID="LN">35  </FONT><A NAME="35"></A>    <FONT ID="Private">private</FONT> String name;
<FONT ID="LN">36  </FONT><A NAME="36"></A>
<FONT ID="LN">37  </FONT><A NAME="37"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">38  </FONT><A NAME="38"></A>     * If true, the in-memory representation of the class will be written to the
<FONT ID="LN">39  </FONT><A NAME="39"></A>     * file system. Otherwise, it won't be saved as a file.
<FONT ID="LN">40  </FONT><A NAME="40"></A>     */</FONT>
<FONT ID="LN">41  </FONT><A NAME="41"></A>    <FONT ID="Private">private</FONT> <FONT ID="Boolean">boolean</FONT> toFile;
<FONT ID="LN">42  </FONT><A NAME="42"></A>
<FONT ID="LN">43  </FONT><A NAME="43"></A>    <FONT ID="FormalComment">/** Destination directory for the class. */</FONT>
<FONT ID="LN">44  </FONT><A NAME="44"></A>    <FONT ID="Private">private</FONT> String destDir;
<FONT ID="LN">45  </FONT><A NAME="45"></A>
<FONT ID="LN">46  </FONT><A NAME="46"></A>    <FONT ID="FormalComment">/** In-memory representation of the class. */</FONT>
<FONT ID="LN">47  </FONT><A NAME="47"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/CLFile.java.html">CLFile</A> clFile;
<FONT ID="LN">48  </FONT><A NAME="48"></A>
<FONT ID="LN">49  </FONT><A NAME="49"></A>    <FONT ID="FormalComment">/** Constant pool of the class. */</FONT>
<FONT ID="LN">50  </FONT><A NAME="50"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/CLConstantPool.java.html">CLConstantPool</A> constantPool;
<FONT ID="LN">51  </FONT><A NAME="51"></A>
<FONT ID="LN">52  </FONT><A NAME="52"></A>    <FONT ID="FormalComment">/** Direct super interfaces of the class. */</FONT>
<FONT ID="LN">53  </FONT><A NAME="53"></A>    <FONT ID="Private">private</FONT> ArrayList&lt;Integer&gt; interfaces;
<FONT ID="LN">54  </FONT><A NAME="54"></A>
<FONT ID="LN">55  </FONT><A NAME="55"></A>    <FONT ID="FormalComment">/** Fields in the class. */</FONT>
<FONT ID="LN">56  </FONT><A NAME="56"></A>    <FONT ID="Private">private</FONT> ArrayList&lt;CLFieldInfo&gt; fields;
<FONT ID="LN">57  </FONT><A NAME="57"></A>
<FONT ID="LN">58  </FONT><A NAME="58"></A>    <FONT ID="FormalComment">/** Attributes of the field last added. */</FONT>
<FONT ID="LN">59  </FONT><A NAME="59"></A>    <FONT ID="Private">private</FONT> ArrayList&lt;<A HREF="../jminusminus/CLAttributeInfo.java.html">CLAttributeInfo</A>&gt; fAttributes;
<FONT ID="LN">60  </FONT><A NAME="60"></A>
<FONT ID="LN">61  </FONT><A NAME="61"></A>    <FONT ID="FormalComment">/** Methods in the class. */</FONT>
<FONT ID="LN">62  </FONT><A NAME="62"></A>    <FONT ID="Private">private</FONT> ArrayList&lt;CLMethodInfo&gt; methods;
<FONT ID="LN">63  </FONT><A NAME="63"></A>
<FONT ID="LN">64  </FONT><A NAME="64"></A>    <FONT ID="FormalComment">/** Attributes of the method last added. */</FONT>
<FONT ID="LN">65  </FONT><A NAME="65"></A>    <FONT ID="Private">private</FONT> ArrayList&lt;<A HREF="../jminusminus/CLAttributeInfo.java.html">CLAttributeInfo</A>&gt; mAttributes;
<FONT ID="LN">66  </FONT><A NAME="66"></A>
<FONT ID="LN">67  </FONT><A NAME="67"></A>    <FONT ID="FormalComment">/** Attributes of the class. */</FONT>
<FONT ID="LN">68  </FONT><A NAME="68"></A>    <FONT ID="Private">private</FONT> ArrayList&lt;<A HREF="../jminusminus/CLAttributeInfo.java.html">CLAttributeInfo</A>&gt; attributes;
<FONT ID="LN">69  </FONT><A NAME="69"></A>
<FONT ID="LN">70  </FONT><A NAME="70"></A>    <FONT ID="FormalComment">/** Inner classes of the class. */</FONT>
<FONT ID="LN">71  </FONT><A NAME="71"></A>    <FONT ID="Private">private</FONT> ArrayList&lt;CLInnerClassInfo&gt; innerClasses;
<FONT ID="LN">72  </FONT><A NAME="72"></A>
<FONT ID="LN">73  </FONT><A NAME="73"></A>    <FONT ID="FormalComment">/** Code (instruction) section of the method last added. */</FONT>
<FONT ID="LN">74  </FONT><A NAME="74"></A>    <FONT ID="Private">private</FONT> ArrayList&lt;<A HREF="../jminusminus/CLInstruction.java.html">CLInstruction</A>&gt; mCode;
<FONT ID="LN">75  </FONT><A NAME="75"></A>
<FONT ID="LN">76  </FONT><A NAME="76"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">77  </FONT><A NAME="77"></A>     * Table containing exception handlers in the method last added.
<FONT ID="LN">78  </FONT><A NAME="78"></A>     */</FONT>
<FONT ID="LN">79  </FONT><A NAME="79"></A>    <FONT ID="Private">private</FONT> ArrayList&lt;CLException&gt; mExceptionHandlers;
<FONT ID="LN">80  </FONT><A NAME="80"></A>
<FONT ID="LN">81  </FONT><A NAME="81"></A>    <FONT ID="FormalComment">/** Access flags of the method last added. */</FONT>
<FONT ID="LN">82  </FONT><A NAME="82"></A>    <FONT ID="Private">private</FONT> <FONT ID="Int">int</FONT> mAccessFlags;
<FONT ID="LN">83  </FONT><A NAME="83"></A>
<FONT ID="LN">84  </FONT><A NAME="84"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">85  </FONT><A NAME="85"></A>     * Index into the constant pool, the item at which specifies the name of the
<FONT ID="LN">86  </FONT><A NAME="86"></A>     * method last added.
<FONT ID="LN">87  </FONT><A NAME="87"></A>     */</FONT>
<FONT ID="LN">88  </FONT><A NAME="88"></A>    <FONT ID="Private">private</FONT> <FONT ID="Int">int</FONT> mNameIndex;
<FONT ID="LN">89  </FONT><A NAME="89"></A>
<FONT ID="LN">90  </FONT><A NAME="90"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">91  </FONT><A NAME="91"></A>     * Index into the constant pool, the item at which specifies the descriptor
<FONT ID="LN">92  </FONT><A NAME="92"></A>     * of the method last added.
<FONT ID="LN">93  </FONT><A NAME="93"></A>     */</FONT>
<FONT ID="LN">94  </FONT><A NAME="94"></A>    <FONT ID="Private">private</FONT> <FONT ID="Int">int</FONT> mDescriptorIndex;
<FONT ID="LN">95  </FONT><A NAME="95"></A>
<FONT ID="LN">96  </FONT><A NAME="96"></A>    <FONT ID="FormalComment">/** Number of arguments for the method last added. */</FONT>
<FONT ID="LN">97  </FONT><A NAME="97"></A>    <FONT ID="Private">private</FONT> <FONT ID="Int">int</FONT> mArgumentCount;
<FONT ID="LN">98  </FONT><A NAME="98"></A>
<FONT ID="LN">99  </FONT><A NAME="99"></A>    <FONT ID="FormalComment">/** Code attributes of the method last added. */</FONT>
<FONT ID="LN">100 </FONT><A NAME="100"></A>    <FONT ID="Private">private</FONT> ArrayList&lt;<A HREF="../jminusminus/CLAttributeInfo.java.html">CLAttributeInfo</A>&gt; mCodeAttributes;
<FONT ID="LN">101 </FONT><A NAME="101"></A>
<FONT ID="LN">102 </FONT><A NAME="102"></A>    <FONT ID="FormalComment">/** Whether the method last added needs closing. */</FONT>
<FONT ID="LN">103 </FONT><A NAME="103"></A>    <FONT ID="Private">private</FONT> <FONT ID="Boolean">boolean</FONT> isMethodOpen;
<FONT ID="LN">104 </FONT><A NAME="104"></A>
<FONT ID="LN">105 </FONT><A NAME="105"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">106 </FONT><A NAME="106"></A>     * Stores jump labels for the method last added. When a label is created, a
<FONT ID="LN">107 </FONT><A NAME="107"></A>     * mapping from the label to an Integer representing the pc of the next
<FONT ID="LN">108 </FONT><A NAME="108"></A>     * instruction is created. Later on, when the label is added, its Integer
<FONT ID="LN">109 </FONT><A NAME="109"></A>     * value is replaced by the value of pc then.
<FONT ID="LN">110 </FONT><A NAME="110"></A>     */</FONT>
<FONT ID="LN">111 </FONT><A NAME="111"></A>    <FONT ID="Private">private</FONT> Hashtable&lt;String, Integer&gt; mLabels;
<FONT ID="LN">112 </FONT><A NAME="112"></A>
<FONT ID="LN">113 </FONT><A NAME="113"></A>    <FONT ID="FormalComment">/** Counter for creating unique jump labels. */</FONT>
<FONT ID="LN">114 </FONT><A NAME="114"></A>    <FONT ID="Private">private</FONT> <FONT ID="Int">int</FONT> mLabelCount;
<FONT ID="LN">115 </FONT><A NAME="115"></A>
<FONT ID="LN">116 </FONT><A NAME="116"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">117 </FONT><A NAME="117"></A>     * Whether there there was an instruction added after the last call to
<FONT ID="LN">118 </FONT><A NAME="118"></A>     * addLabel( String label ). If not, the branch instruction that was added
<FONT ID="LN">119 </FONT><A NAME="119"></A>     * with that label would jump beyond the code section, which is not
<FONT ID="LN">120 </FONT><A NAME="120"></A>     * acceptable to the runtime class loader. Therefore, if this flag is false,
<FONT ID="LN">121 </FONT><A NAME="121"></A>     * we add a NOP instruction at the end of the code section to make the jump
<FONT ID="LN">122 </FONT><A NAME="122"></A>     * valid.
<FONT ID="LN">123 </FONT><A NAME="123"></A>     */</FONT>
<FONT ID="LN">124 </FONT><A NAME="124"></A>    <FONT ID="Private">private</FONT> <FONT ID="Boolean">boolean</FONT> mInstructionAfterLabel = <FONT ID="False">false</FONT>;
<FONT ID="LN">125 </FONT><A NAME="125"></A>
<FONT ID="LN">126 </FONT><A NAME="126"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">127 </FONT><A NAME="127"></A>     * Location counter; index of the next instruction within the code section
<FONT ID="LN">128 </FONT><A NAME="128"></A>     * of the method last added.
<FONT ID="LN">129 </FONT><A NAME="129"></A>     */</FONT>
<FONT ID="LN">130 </FONT><A NAME="130"></A>    <FONT ID="Private">private</FONT> <FONT ID="Int">int</FONT> mPC;
<FONT ID="LN">131 </FONT><A NAME="131"></A>
<FONT ID="LN">132 </FONT><A NAME="132"></A>    <FONT ID="FormalComment">/** Name of the method last added; used for error reporting. */</FONT>
<FONT ID="LN">133 </FONT><A NAME="133"></A>    <FONT ID="Private">private</FONT> String eCurrentMethod;
<FONT ID="LN">134 </FONT><A NAME="134"></A>
<FONT ID="LN">135 </FONT><A NAME="135"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">136 </FONT><A NAME="136"></A>     * Whether an error occurred while creating/writing the class.
<FONT ID="LN">137 </FONT><A NAME="137"></A>     */</FONT>
<FONT ID="LN">138 </FONT><A NAME="138"></A>    <FONT ID="Private">private</FONT> <FONT ID="Boolean">boolean</FONT> errorHasOccurred;
<FONT ID="LN">139 </FONT><A NAME="139"></A>
<FONT ID="LN">140 </FONT><A NAME="140"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">141 </FONT><A NAME="141"></A>     * Class loader to use for creating in-memory representation of classes from
<FONT ID="LN">142 </FONT><A NAME="142"></A>     * byte streams.
<FONT ID="LN">143 </FONT><A NAME="143"></A>     */</FONT>
<FONT ID="LN">144 </FONT><A NAME="144"></A>    <FONT ID="Private">private</FONT> <FONT ID="Static">static</FONT> ByteClassLoader byteClassLoader;
<FONT ID="LN">145 </FONT><A NAME="145"></A>
<FONT ID="LN">146 </FONT><A NAME="146"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">147 </FONT><A NAME="147"></A>     * Initialize all variables used for adding a method to the ClassFile
<FONT ID="LN">148 </FONT><A NAME="148"></A>     * structure to their appropriate values.
<FONT ID="LN">149 </FONT><A NAME="149"></A>     */</FONT>
<FONT ID="LN">150 </FONT><A NAME="150"></A>
<FONT ID="LN">151 </FONT><A NAME="151"></A>    <FONT ID="Private">private</FONT> <FONT ID="Void">void</FONT> initializeMethodVariables() {
<FONT ID="LN">152 </FONT><A NAME="152"></A>        mAccessFlags = <FONT ID="IntegerLiteral">0</FONT>;
<FONT ID="LN">153 </FONT><A NAME="153"></A>        mNameIndex = -<FONT ID="IntegerLiteral">1</FONT>;
<FONT ID="LN">154 </FONT><A NAME="154"></A>        mDescriptorIndex = -<FONT ID="IntegerLiteral">1</FONT>;
<FONT ID="LN">155 </FONT><A NAME="155"></A>        mArgumentCount = <FONT ID="IntegerLiteral">0</FONT>;
<FONT ID="LN">156 </FONT><A NAME="156"></A>        mPC = <FONT ID="IntegerLiteral">0</FONT>;
<FONT ID="LN">157 </FONT><A NAME="157"></A>        mAttributes = <FONT ID="New">new</FONT> ArrayList&lt;<A HREF="../jminusminus/CLAttributeInfo.java.html">CLAttributeInfo</A>&gt;();
<FONT ID="LN">158 </FONT><A NAME="158"></A>        mExceptionHandlers = <FONT ID="New">new</FONT> ArrayList&lt;CLException&gt;();
<FONT ID="LN">159 </FONT><A NAME="159"></A>        mCode = <FONT ID="New">new</FONT> ArrayList&lt;<A HREF="../jminusminus/CLInstruction.java.html">CLInstruction</A>&gt;();
<FONT ID="LN">160 </FONT><A NAME="160"></A>        mCodeAttributes = <FONT ID="New">new</FONT> ArrayList&lt;<A HREF="../jminusminus/CLAttributeInfo.java.html">CLAttributeInfo</A>&gt;();
<FONT ID="LN">161 </FONT><A NAME="161"></A>        mLabels = <FONT ID="New">new</FONT> Hashtable&lt;String, Integer&gt;();
<FONT ID="LN">162 </FONT><A NAME="162"></A>        mLabelCount = <FONT ID="IntegerLiteral">1</FONT>;
<FONT ID="LN">163 </FONT><A NAME="163"></A>        mInstructionAfterLabel = <FONT ID="False">false</FONT>;
<FONT ID="LN">164 </FONT><A NAME="164"></A>    }
<FONT ID="LN">165 </FONT><A NAME="165"></A>
<FONT ID="LN">166 </FONT><A NAME="166"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">167 </FONT><A NAME="167"></A>     * Add the method created using addMethod() to the ClassFile structure. This
<FONT ID="LN">168 </FONT><A NAME="168"></A>     * involves adding an instance of CLMethodInfo to ClassFile.methods for the
<FONT ID="LN">169 </FONT><A NAME="169"></A>     * method.
<FONT ID="LN">170 </FONT><A NAME="170"></A>     */</FONT>
<FONT ID="LN">171 </FONT><A NAME="171"></A>
<FONT ID="LN">172 </FONT><A NAME="172"></A>    <FONT ID="Private">private</FONT> <FONT ID="Void">void</FONT> endOpenMethodIfAny() {
<FONT ID="LN">173 </FONT><A NAME="173"></A>        <FONT ID="If">if</FONT> (isMethodOpen) {
<FONT ID="LN">174 </FONT><A NAME="174"></A>            isMethodOpen = <FONT ID="False">false</FONT>;
<FONT ID="LN">175 </FONT><A NAME="175"></A>            <FONT ID="If">if</FONT> (!mInstructionAfterLabel) {
<FONT ID="LN">176 </FONT><A NAME="176"></A>                <FONT ID="SingleLineComment">// Must jump to an instruction
<FONT ID="LN">177 </FONT><A NAME="177"></A></FONT>                addNoArgInstruction(NOP);
<FONT ID="LN">178 </FONT><A NAME="178"></A>            }
<FONT ID="LN">179 </FONT><A NAME="179"></A>
<FONT ID="LN">180 </FONT><A NAME="180"></A>            <FONT ID="SingleLineComment">// Resolve jump labels in exception handlers
<FONT ID="LN">181 </FONT><A NAME="181"></A></FONT>            ArrayList&lt;CLExceptionInfo&gt; exceptionTable = <FONT ID="New">new</FONT> ArrayList&lt;CLExceptionInfo&gt;();
<FONT ID="LN">182 </FONT><A NAME="182"></A>            <FONT ID="For">for</FONT> (<FONT ID="Int">int</FONT> i = <FONT ID="IntegerLiteral">0</FONT>; i &lt; mExceptionHandlers.size(); i++) {
<FONT ID="LN">183 </FONT><A NAME="183"></A>                CLException e = mExceptionHandlers.get(i);
<FONT ID="LN">184 </FONT><A NAME="184"></A>                <FONT ID="If">if</FONT> (!e.resolveLabels(mLabels)) {
<FONT ID="LN">185 </FONT><A NAME="185"></A>                    reportEmitterError(
<FONT ID="LN">186 </FONT><A NAME="186"></A>                            <FONT ID="StringLiteral">"%s: Unable to resolve exception handler "</FONT>
<FONT ID="LN">187 </FONT><A NAME="187"></A>                                    + <FONT ID="StringLiteral">"label(s)"</FONT>, eCurrentMethod);
<FONT ID="LN">188 </FONT><A NAME="188"></A>                }
<FONT ID="LN">189 </FONT><A NAME="189"></A>
<FONT ID="LN">190 </FONT><A NAME="190"></A>                <FONT ID="SingleLineComment">// We allow catchType to be null (mapping to
<FONT ID="LN">191 </FONT><A NAME="191"></A></FONT>                <FONT ID="SingleLineComment">// index 0),
<FONT ID="LN">192 </FONT><A NAME="192"></A></FONT>                <FONT ID="SingleLineComment">// implying this exception handler is called for
<FONT ID="LN">193 </FONT><A NAME="193"></A></FONT>                <FONT ID="SingleLineComment">// all
<FONT ID="LN">194 </FONT><A NAME="194"></A></FONT>                <FONT ID="SingleLineComment">// exceptions. This is used to implement
<FONT ID="LN">195 </FONT><A NAME="195"></A></FONT>                <FONT ID="SingleLineComment">// "finally"
<FONT ID="LN">196 </FONT><A NAME="196"></A></FONT>                <FONT ID="Int">int</FONT> catchTypeIndex = (e.catchType == <FONT ID="Null">null</FONT>) ? <FONT ID="IntegerLiteral">0</FONT> : constantPool
<FONT ID="LN">197 </FONT><A NAME="197"></A>                        .constantClassInfo(e.catchType);
<FONT ID="LN">198 </FONT><A NAME="198"></A>                CLExceptionInfo c = <FONT ID="New">new</FONT> CLExceptionInfo(e.startPC, e.endPC,
<FONT ID="LN">199 </FONT><A NAME="199"></A>                        e.handlerPC, catchTypeIndex);
<FONT ID="LN">200 </FONT><A NAME="200"></A>                exceptionTable.add(c);
<FONT ID="LN">201 </FONT><A NAME="201"></A>            }
<FONT ID="LN">202 </FONT><A NAME="202"></A>
<FONT ID="LN">203 </FONT><A NAME="203"></A>            <FONT ID="SingleLineComment">// Convert Instruction objects to bytes
<FONT ID="LN">204 </FONT><A NAME="204"></A></FONT>            ArrayList&lt;Integer&gt; byteCode = <FONT ID="New">new</FONT> ArrayList&lt;Integer&gt;();
<FONT ID="LN">205 </FONT><A NAME="205"></A>            <FONT ID="Int">int</FONT> maxLocals = mArgumentCount;
<FONT ID="LN">206 </FONT><A NAME="206"></A>            <FONT ID="For">for</FONT> (<FONT ID="Int">int</FONT> i = <FONT ID="IntegerLiteral">0</FONT>; i &lt; mCode.size(); i++) {
<FONT ID="LN">207 </FONT><A NAME="207"></A>                <A HREF="../jminusminus/CLInstruction.java.html">CLInstruction</A> instr = mCode.get(i);
<FONT ID="LN">208 </FONT><A NAME="208"></A>
<FONT ID="LN">209 </FONT><A NAME="209"></A>                <FONT ID="SingleLineComment">// Compute maxLocals
<FONT ID="LN">210 </FONT><A NAME="210"></A></FONT>                <FONT ID="Int">int</FONT> localVariableIndex = instr.localVariableIndex();
<FONT ID="LN">211 </FONT><A NAME="211"></A>                <FONT ID="Switch">switch</FONT> (instr.opcode()) {
<FONT ID="LN">212 </FONT><A NAME="212"></A>                <FONT ID="Case">case</FONT> LLOAD:
<FONT ID="LN">213 </FONT><A NAME="213"></A>                <FONT ID="Case">case</FONT> LSTORE:
<FONT ID="LN">214 </FONT><A NAME="214"></A>                <FONT ID="Case">case</FONT> DSTORE:
<FONT ID="LN">215 </FONT><A NAME="215"></A>                <FONT ID="Case">case</FONT> DLOAD:
<FONT ID="LN">216 </FONT><A NAME="216"></A>                <FONT ID="Case">case</FONT> LLOAD_0:
<FONT ID="LN">217 </FONT><A NAME="217"></A>                <FONT ID="Case">case</FONT> LLOAD_1:
<FONT ID="LN">218 </FONT><A NAME="218"></A>                <FONT ID="Case">case</FONT> LLOAD_2:
<FONT ID="LN">219 </FONT><A NAME="219"></A>                <FONT ID="Case">case</FONT> LLOAD_3:
<FONT ID="LN">220 </FONT><A NAME="220"></A>                <FONT ID="Case">case</FONT> LSTORE_0:
<FONT ID="LN">221 </FONT><A NAME="221"></A>                <FONT ID="Case">case</FONT> LSTORE_1:
<FONT ID="LN">222 </FONT><A NAME="222"></A>                <FONT ID="Case">case</FONT> LSTORE_2:
<FONT ID="LN">223 </FONT><A NAME="223"></A>                <FONT ID="Case">case</FONT> LSTORE_3:
<FONT ID="LN">224 </FONT><A NAME="224"></A>                <FONT ID="Case">case</FONT> DLOAD_0:
<FONT ID="LN">225 </FONT><A NAME="225"></A>                <FONT ID="Case">case</FONT> DLOAD_1:
<FONT ID="LN">226 </FONT><A NAME="226"></A>                <FONT ID="Case">case</FONT> DLOAD_2:
<FONT ID="LN">227 </FONT><A NAME="227"></A>                <FONT ID="Case">case</FONT> DLOAD_3:
<FONT ID="LN">228 </FONT><A NAME="228"></A>                <FONT ID="Case">case</FONT> DSTORE_0:
<FONT ID="LN">229 </FONT><A NAME="229"></A>                <FONT ID="Case">case</FONT> DSTORE_1:
<FONT ID="LN">230 </FONT><A NAME="230"></A>                <FONT ID="Case">case</FONT> DSTORE_2:
<FONT ID="LN">231 </FONT><A NAME="231"></A>                <FONT ID="Case">case</FONT> DSTORE_3:
<FONT ID="LN">232 </FONT><A NAME="232"></A>                    <FONT ID="SingleLineComment">// Each long and double occupies two slots in
<FONT ID="LN">233 </FONT><A NAME="233"></A></FONT>                    <FONT ID="SingleLineComment">// the
<FONT ID="LN">234 </FONT><A NAME="234"></A></FONT>                    <FONT ID="SingleLineComment">// local variable table
<FONT ID="LN">235 </FONT><A NAME="235"></A></FONT>                    localVariableIndex++;
<FONT ID="LN">236 </FONT><A NAME="236"></A>                }
<FONT ID="LN">237 </FONT><A NAME="237"></A>                maxLocals = Math.max(maxLocals, localVariableIndex + <FONT ID="IntegerLiteral">1</FONT>);
<FONT ID="LN">238 </FONT><A NAME="238"></A>
<FONT ID="LN">239 </FONT><A NAME="239"></A>                <FONT ID="SingleLineComment">// Resolve jump labels in flow control
<FONT ID="LN">240 </FONT><A NAME="240"></A></FONT>                <FONT ID="SingleLineComment">// instructions
<FONT ID="LN">241 </FONT><A NAME="241"></A></FONT>                <FONT ID="If">if</FONT> (instr <FONT ID="InstanceOf">instanceof</FONT> CLFlowControlInstruction) {
<FONT ID="LN">242 </FONT><A NAME="242"></A>                    <FONT ID="If">if</FONT> (!((CLFlowControlInstruction) instr)
<FONT ID="LN">243 </FONT><A NAME="243"></A>                            .resolveLabels(mLabels)) {
<FONT ID="LN">244 </FONT><A NAME="244"></A>                        reportEmitterError(
<FONT ID="LN">245 </FONT><A NAME="245"></A>                                <FONT ID="StringLiteral">"%s: Unable to resolve jump label(s)"</FONT>,
<FONT ID="LN">246 </FONT><A NAME="246"></A>                                eCurrentMethod);
<FONT ID="LN">247 </FONT><A NAME="247"></A>                    }
<FONT ID="LN">248 </FONT><A NAME="248"></A>                }
<FONT ID="LN">249 </FONT><A NAME="249"></A>
<FONT ID="LN">250 </FONT><A NAME="250"></A>                byteCode.addAll(instr.toBytes());
<FONT ID="LN">251 </FONT><A NAME="251"></A>            }
<FONT ID="LN">252 </FONT><A NAME="252"></A>
<FONT ID="LN">253 </FONT><A NAME="253"></A>            <FONT ID="SingleLineComment">// Code attribute; add only if method is neither
<FONT ID="LN">254 </FONT><A NAME="254"></A></FONT>            <FONT ID="SingleLineComment">// native
<FONT ID="LN">255 </FONT><A NAME="255"></A></FONT>            <FONT ID="SingleLineComment">// nor abstract
<FONT ID="LN">256 </FONT><A NAME="256"></A></FONT>            <FONT ID="If">if</FONT> (!((mAccessFlags &amp; ACC_NATIVE) == ACC_NATIVE || (mAccessFlags &amp; ACC_ABSTRACT) == ACC_ABSTRACT)) {
<FONT ID="LN">257 </FONT><A NAME="257"></A>                addMethodAttribute(codeAttribute(byteCode, exceptionTable,
<FONT ID="LN">258 </FONT><A NAME="258"></A>                        stackDepth(), maxLocals));
<FONT ID="LN">259 </FONT><A NAME="259"></A>            }
<FONT ID="LN">260 </FONT><A NAME="260"></A>
<FONT ID="LN">261 </FONT><A NAME="261"></A>            methods.add(<FONT ID="New">new</FONT> CLMethodInfo(mAccessFlags, mNameIndex,
<FONT ID="LN">262 </FONT><A NAME="262"></A>                    mDescriptorIndex, mAttributes.size(), mAttributes));
<FONT ID="LN">263 </FONT><A NAME="263"></A>        }
<FONT ID="LN">264 </FONT><A NAME="264"></A>
<FONT ID="LN">265 </FONT><A NAME="265"></A>        <FONT ID="SingleLineComment">// This method could be the last method, so we need
<FONT ID="LN">266 </FONT><A NAME="266"></A></FONT>        <FONT ID="SingleLineComment">// the following wrap up code
<FONT ID="LN">267 </FONT><A NAME="267"></A></FONT>
<FONT ID="LN">268 </FONT><A NAME="268"></A>        <FONT ID="SingleLineComment">// Add the InnerClass attribute if this class has inner
<FONT ID="LN">269 </FONT><A NAME="269"></A></FONT>        <FONT ID="SingleLineComment">// classes
<FONT ID="LN">270 </FONT><A NAME="270"></A></FONT>        <FONT ID="If">if</FONT> (innerClasses.size() &gt; <FONT ID="IntegerLiteral">0</FONT>) {
<FONT ID="LN">271 </FONT><A NAME="271"></A>            addClassAttribute(innerClassesAttribute());
<FONT ID="LN">272 </FONT><A NAME="272"></A>        }
<FONT ID="LN">273 </FONT><A NAME="273"></A>
<FONT ID="LN">274 </FONT><A NAME="274"></A>        <FONT ID="SingleLineComment">// Set the members of the ClassFile structure to their
<FONT ID="LN">275 </FONT><A NAME="275"></A></FONT>        <FONT ID="SingleLineComment">// appropriate values
<FONT ID="LN">276 </FONT><A NAME="276"></A></FONT>        clFile.constantPoolCount = constantPool.size() + <FONT ID="IntegerLiteral">1</FONT>;
<FONT ID="LN">277 </FONT><A NAME="277"></A>        clFile.constantPool = constantPool;
<FONT ID="LN">278 </FONT><A NAME="278"></A>        clFile.interfacesCount = interfaces.size();
<FONT ID="LN">279 </FONT><A NAME="279"></A>        clFile.interfaces = interfaces;
<FONT ID="LN">280 </FONT><A NAME="280"></A>        clFile.fieldsCount = fields.size();
<FONT ID="LN">281 </FONT><A NAME="281"></A>        clFile.fields = fields;
<FONT ID="LN">282 </FONT><A NAME="282"></A>        clFile.methodsCount = methods.size();
<FONT ID="LN">283 </FONT><A NAME="283"></A>        clFile.methods = methods;
<FONT ID="LN">284 </FONT><A NAME="284"></A>        clFile.attributesCount = attributes.size();
<FONT ID="LN">285 </FONT><A NAME="285"></A>        clFile.attributes = attributes;
<FONT ID="LN">286 </FONT><A NAME="286"></A>    }
<FONT ID="LN">287 </FONT><A NAME="287"></A>
<FONT ID="LN">288 </FONT><A NAME="288"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">289 </FONT><A NAME="289"></A>     * Add a field.
<FONT ID="LN">290 </FONT><A NAME="290"></A>     * 
<FONT ID="LN">291 </FONT><A NAME="291"></A>     * @param accessFlags
<FONT ID="LN">292 </FONT><A NAME="292"></A>     *            access flags for the field.
<FONT ID="LN">293 </FONT><A NAME="293"></A>     * @param name
<FONT ID="LN">294 </FONT><A NAME="294"></A>     *            name of the field.
<FONT ID="LN">295 </FONT><A NAME="295"></A>     * @param type
<FONT ID="LN">296 </FONT><A NAME="296"></A>     *            type descriptor for the field.
<FONT ID="LN">297 </FONT><A NAME="297"></A>     * @param isSynthetic
<FONT ID="LN">298 </FONT><A NAME="298"></A>     *            is this a synthetic field?
<FONT ID="LN">299 </FONT><A NAME="299"></A>     * @param c
<FONT ID="LN">300 </FONT><A NAME="300"></A>     *            index into the constant pool at which there is a
<FONT ID="LN">301 </FONT><A NAME="301"></A>     *            ConstantIntegerInfo, ConstantFloatInfo, ConstantLongInfo,
<FONT ID="LN">302 </FONT><A NAME="302"></A>     *            ConstantDoubleInfo or ConstantStringInfo object. c is -1 if
<FONT ID="LN">303 </FONT><A NAME="303"></A>     *            the field does not have an initialization.
<FONT ID="LN">304 </FONT><A NAME="304"></A>     */</FONT>
<FONT ID="LN">305 </FONT><A NAME="305"></A>
<FONT ID="LN">306 </FONT><A NAME="306"></A>    <FONT ID="Private">private</FONT> <FONT ID="Void">void</FONT> addFieldInfo(ArrayList&lt;String&gt; accessFlags, String name,
<FONT ID="LN">307 </FONT><A NAME="307"></A>            String type, <FONT ID="Boolean">boolean</FONT> isSynthetic, <FONT ID="Int">int</FONT> c) {
<FONT ID="LN">308 </FONT><A NAME="308"></A>        <FONT ID="If">if</FONT> (!validTypeDescriptor(type)) {
<FONT ID="LN">309 </FONT><A NAME="309"></A>            reportEmitterError(<FONT ID="StringLiteral">"'%s' is not a valid type descriptor for field"</FONT>,
<FONT ID="LN">310 </FONT><A NAME="310"></A>                    type);
<FONT ID="LN">311 </FONT><A NAME="311"></A>        }
<FONT ID="LN">312 </FONT><A NAME="312"></A>        <FONT ID="Int">int</FONT> flags = <FONT ID="IntegerLiteral">0</FONT>;
<FONT ID="LN">313 </FONT><A NAME="313"></A>        <FONT ID="Int">int</FONT> nameIndex = constantPool.constantUtf8Info(name);
<FONT ID="LN">314 </FONT><A NAME="314"></A>        <FONT ID="Int">int</FONT> descriptorIndex = constantPool.constantUtf8Info(type);
<FONT ID="LN">315 </FONT><A NAME="315"></A>        fAttributes = <FONT ID="New">new</FONT> ArrayList&lt;<A HREF="../jminusminus/CLAttributeInfo.java.html">CLAttributeInfo</A>&gt;();
<FONT ID="LN">316 </FONT><A NAME="316"></A>        <FONT ID="If">if</FONT> (accessFlags != <FONT ID="Null">null</FONT>) {
<FONT ID="LN">317 </FONT><A NAME="317"></A>            <FONT ID="For">for</FONT> (<FONT ID="Int">int</FONT> i = <FONT ID="IntegerLiteral">0</FONT>; i &lt; accessFlags.size(); i++) {
<FONT ID="LN">318 </FONT><A NAME="318"></A>                flags |= CLFile.accessFlagToInt(accessFlags.get(i));
<FONT ID="LN">319 </FONT><A NAME="319"></A>            }
<FONT ID="LN">320 </FONT><A NAME="320"></A>        }
<FONT ID="LN">321 </FONT><A NAME="321"></A>        <FONT ID="If">if</FONT> (isSynthetic) {
<FONT ID="LN">322 </FONT><A NAME="322"></A>            addFieldAttribute(syntheticAttribute());
<FONT ID="LN">323 </FONT><A NAME="323"></A>        }
<FONT ID="LN">324 </FONT><A NAME="324"></A>        <FONT ID="If">if</FONT> (c != -<FONT ID="IntegerLiteral">1</FONT>) {
<FONT ID="LN">325 </FONT><A NAME="325"></A>            addFieldAttribute(constantValueAttribute(c));
<FONT ID="LN">326 </FONT><A NAME="326"></A>        }
<FONT ID="LN">327 </FONT><A NAME="327"></A>        fields.add(<FONT ID="New">new</FONT> CLFieldInfo(flags, nameIndex, descriptorIndex,
<FONT ID="LN">328 </FONT><A NAME="328"></A>                fAttributes.size(), fAttributes));
<FONT ID="LN">329 </FONT><A NAME="329"></A>    }
<FONT ID="LN">330 </FONT><A NAME="330"></A>
<FONT ID="LN">331 </FONT><A NAME="331"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">332 </FONT><A NAME="332"></A>     * Return the number of units a type with the specified descriptor produces
<FONT ID="LN">333 </FONT><A NAME="333"></A>     * or consumes from the operand stack. 0 is returned if the specified
<FONT ID="LN">334 </FONT><A NAME="334"></A>     * descriptor is invalid.
<FONT ID="LN">335 </FONT><A NAME="335"></A>     * 
<FONT ID="LN">336 </FONT><A NAME="336"></A>     * @param descriptor
<FONT ID="LN">337 </FONT><A NAME="337"></A>     *            a type descriptor.
<FONT ID="LN">338 </FONT><A NAME="338"></A>     * @return the number of units produced or consumed in/from the operand
<FONT ID="LN">339 </FONT><A NAME="339"></A>     *         stack.
<FONT ID="LN">340 </FONT><A NAME="340"></A>     */</FONT>
<FONT ID="LN">341 </FONT><A NAME="341"></A>
<FONT ID="LN">342 </FONT><A NAME="342"></A>    <FONT ID="Private">private</FONT> <FONT ID="Int">int</FONT> typeStackResidue(String descriptor) {
<FONT ID="LN">343 </FONT><A NAME="343"></A>        <FONT ID="Int">int</FONT> i = <FONT ID="IntegerLiteral">0</FONT>;
<FONT ID="LN">344 </FONT><A NAME="344"></A>        <FONT ID="Char">char</FONT> c = descriptor.charAt(<FONT ID="IntegerLiteral">0</FONT>);
<FONT ID="LN">345 </FONT><A NAME="345"></A>        <FONT ID="Switch">switch</FONT> (c) {
<FONT ID="LN">346 </FONT><A NAME="346"></A>        <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'B'</FONT>:
<FONT ID="LN">347 </FONT><A NAME="347"></A>        <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'C'</FONT>:
<FONT ID="LN">348 </FONT><A NAME="348"></A>        <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'I'</FONT>:
<FONT ID="LN">349 </FONT><A NAME="349"></A>        <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'F'</FONT>:
<FONT ID="LN">350 </FONT><A NAME="350"></A>        <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'L'</FONT>:
<FONT ID="LN">351 </FONT><A NAME="351"></A>        <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'S'</FONT>:
<FONT ID="LN">352 </FONT><A NAME="352"></A>        <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'Z'</FONT>:
<FONT ID="LN">353 </FONT><A NAME="353"></A>        <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'['</FONT>:
<FONT ID="LN">354 </FONT><A NAME="354"></A>            i = <FONT ID="IntegerLiteral">1</FONT>;
<FONT ID="LN">355 </FONT><A NAME="355"></A>            <FONT ID="Break">break</FONT>;
<FONT ID="LN">356 </FONT><A NAME="356"></A>        <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'J'</FONT>:
<FONT ID="LN">357 </FONT><A NAME="357"></A>        <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'D'</FONT>:
<FONT ID="LN">358 </FONT><A NAME="358"></A>            i = <FONT ID="IntegerLiteral">2</FONT>;
<FONT ID="LN">359 </FONT><A NAME="359"></A>            <FONT ID="Break">break</FONT>;
<FONT ID="LN">360 </FONT><A NAME="360"></A>        }
<FONT ID="LN">361 </FONT><A NAME="361"></A>        <FONT ID="Return">return</FONT> i;
<FONT ID="LN">362 </FONT><A NAME="362"></A>    }
<FONT ID="LN">363 </FONT><A NAME="363"></A>
<FONT ID="LN">364 </FONT><A NAME="364"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">365 </FONT><A NAME="365"></A>     * Return the difference between the number of units consumed from the
<FONT ID="LN">366 </FONT><A NAME="366"></A>     * operand stack by a method with the specified descriptor and the number of
<FONT ID="LN">367 </FONT><A NAME="367"></A>     * units produced by the method in the operand stack. 0 is returned if the
<FONT ID="LN">368 </FONT><A NAME="368"></A>     * descriptor is invalid.
<FONT ID="LN">369 </FONT><A NAME="369"></A>     * 
<FONT ID="LN">370 </FONT><A NAME="370"></A>     * @param descriptor
<FONT ID="LN">371 </FONT><A NAME="371"></A>     *            a method descriptor.
<FONT ID="LN">372 </FONT><A NAME="372"></A>     * @return number of units consumed from the operand stack - number of units
<FONT ID="LN">373 </FONT><A NAME="373"></A>     *         produced in the stack.
<FONT ID="LN">374 </FONT><A NAME="374"></A>     */</FONT>
<FONT ID="LN">375 </FONT><A NAME="375"></A>
<FONT ID="LN">376 </FONT><A NAME="376"></A>    <FONT ID="Private">private</FONT> <FONT ID="Int">int</FONT> methodStackResidue(String descriptor) {
<FONT ID="LN">377 </FONT><A NAME="377"></A>        <FONT ID="Int">int</FONT> i = <FONT ID="IntegerLiteral">0</FONT>;
<FONT ID="LN">378 </FONT><A NAME="378"></A>
<FONT ID="LN">379 </FONT><A NAME="379"></A>        <FONT ID="SingleLineComment">// Extract types of arguments and the return type from
<FONT ID="LN">380 </FONT><A NAME="380"></A></FONT>        <FONT ID="SingleLineComment">// the method descriptor
<FONT ID="LN">381 </FONT><A NAME="381"></A></FONT>        String argTypes = descriptor.substring(<FONT ID="IntegerLiteral">1</FONT>, descriptor.lastIndexOf(<FONT ID="StringLiteral">")"</FONT>));
<FONT ID="LN">382 </FONT><A NAME="382"></A>        String returnType = descriptor
<FONT ID="LN">383 </FONT><A NAME="383"></A>                .substring(descriptor.lastIndexOf(<FONT ID="StringLiteral">")"</FONT>) + <FONT ID="IntegerLiteral">1</FONT>);
<FONT ID="LN">384 </FONT><A NAME="384"></A>
<FONT ID="LN">385 </FONT><A NAME="385"></A>        <FONT ID="SingleLineComment">// Units consumed
<FONT ID="LN">386 </FONT><A NAME="386"></A></FONT>        <FONT ID="For">for</FONT> (<FONT ID="Int">int</FONT> j = <FONT ID="IntegerLiteral">0</FONT>; j &lt; argTypes.length(); j++) {
<FONT ID="LN">387 </FONT><A NAME="387"></A>            <FONT ID="Char">char</FONT> c = argTypes.charAt(j);
<FONT ID="LN">388 </FONT><A NAME="388"></A>            <FONT ID="Switch">switch</FONT> (c) {
<FONT ID="LN">389 </FONT><A NAME="389"></A>            <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'B'</FONT>:
<FONT ID="LN">390 </FONT><A NAME="390"></A>            <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'C'</FONT>:
<FONT ID="LN">391 </FONT><A NAME="391"></A>            <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'I'</FONT>:
<FONT ID="LN">392 </FONT><A NAME="392"></A>            <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'F'</FONT>:
<FONT ID="LN">393 </FONT><A NAME="393"></A>            <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'S'</FONT>:
<FONT ID="LN">394 </FONT><A NAME="394"></A>            <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'Z'</FONT>:
<FONT ID="LN">395 </FONT><A NAME="395"></A>                i -= <FONT ID="IntegerLiteral">1</FONT>;
<FONT ID="LN">396 </FONT><A NAME="396"></A>                <FONT ID="Break">break</FONT>;
<FONT ID="LN">397 </FONT><A NAME="397"></A>            <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'['</FONT>:
<FONT ID="LN">398 </FONT><A NAME="398"></A>                <FONT ID="Break">break</FONT>;
<FONT ID="LN">399 </FONT><A NAME="399"></A>            <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'J'</FONT>:
<FONT ID="LN">400 </FONT><A NAME="400"></A>            <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'D'</FONT>:
<FONT ID="LN">401 </FONT><A NAME="401"></A>                i -= <FONT ID="IntegerLiteral">2</FONT>;
<FONT ID="LN">402 </FONT><A NAME="402"></A>                <FONT ID="Break">break</FONT>;
<FONT ID="LN">403 </FONT><A NAME="403"></A>            <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'L'</FONT>:
<FONT ID="LN">404 </FONT><A NAME="404"></A>                <FONT ID="Int">int</FONT> k = argTypes.indexOf(<FONT ID="StringLiteral">";"</FONT>, j);
<FONT ID="LN">405 </FONT><A NAME="405"></A>                j = k;
<FONT ID="LN">406 </FONT><A NAME="406"></A>                i -= <FONT ID="IntegerLiteral">1</FONT>;
<FONT ID="LN">407 </FONT><A NAME="407"></A>                <FONT ID="Break">break</FONT>;
<FONT ID="LN">408 </FONT><A NAME="408"></A>            }
<FONT ID="LN">409 </FONT><A NAME="409"></A>        }
<FONT ID="LN">410 </FONT><A NAME="410"></A>
<FONT ID="LN">411 </FONT><A NAME="411"></A>        <FONT ID="SingleLineComment">// Units produced
<FONT ID="LN">412 </FONT><A NAME="412"></A></FONT>        i += typeStackResidue(returnType);
<FONT ID="LN">413 </FONT><A NAME="413"></A>        <FONT ID="Return">return</FONT> i;
<FONT ID="LN">414 </FONT><A NAME="414"></A>    }
<FONT ID="LN">415 </FONT><A NAME="415"></A>
<FONT ID="LN">416 </FONT><A NAME="416"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">417 </FONT><A NAME="417"></A>     * Return the argument count (number of formal parameters) for the specified
<FONT ID="LN">418 </FONT><A NAME="418"></A>     * method. 0 is returned if the descriptor is invalid.
<FONT ID="LN">419 </FONT><A NAME="419"></A>     * 
<FONT ID="LN">420 </FONT><A NAME="420"></A>     * @param descriptor
<FONT ID="LN">421 </FONT><A NAME="421"></A>     *            method descriptor.
<FONT ID="LN">422 </FONT><A NAME="422"></A>     * @return argument count for the specified method.
<FONT ID="LN">423 </FONT><A NAME="423"></A>     */</FONT>
<FONT ID="LN">424 </FONT><A NAME="424"></A>
<FONT ID="LN">425 </FONT><A NAME="425"></A>    <FONT ID="Private">private</FONT> <FONT ID="Int">int</FONT> argumentCount(String descriptor) {
<FONT ID="LN">426 </FONT><A NAME="426"></A>        <FONT ID="Int">int</FONT> i = <FONT ID="IntegerLiteral">0</FONT>;
<FONT ID="LN">427 </FONT><A NAME="427"></A>
<FONT ID="LN">428 </FONT><A NAME="428"></A>        <FONT ID="SingleLineComment">// Extract types of arguments and the return type from
<FONT ID="LN">429 </FONT><A NAME="429"></A></FONT>        <FONT ID="SingleLineComment">// the method descriptor
<FONT ID="LN">430 </FONT><A NAME="430"></A></FONT>        String argTypes = descriptor.substring(<FONT ID="IntegerLiteral">1</FONT>, descriptor.lastIndexOf(<FONT ID="StringLiteral">")"</FONT>));
<FONT ID="LN">431 </FONT><A NAME="431"></A>
<FONT ID="LN">432 </FONT><A NAME="432"></A>        <FONT ID="SingleLineComment">// Find number of arguments
<FONT ID="LN">433 </FONT><A NAME="433"></A></FONT>        <FONT ID="For">for</FONT> (<FONT ID="Int">int</FONT> j = <FONT ID="IntegerLiteral">0</FONT>; j &lt; argTypes.length(); j++) {
<FONT ID="LN">434 </FONT><A NAME="434"></A>            <FONT ID="Char">char</FONT> c = argTypes.charAt(j);
<FONT ID="LN">435 </FONT><A NAME="435"></A>            <FONT ID="Switch">switch</FONT> (c) {
<FONT ID="LN">436 </FONT><A NAME="436"></A>            <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'B'</FONT>:
<FONT ID="LN">437 </FONT><A NAME="437"></A>            <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'C'</FONT>:
<FONT ID="LN">438 </FONT><A NAME="438"></A>            <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'I'</FONT>:
<FONT ID="LN">439 </FONT><A NAME="439"></A>            <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'F'</FONT>:
<FONT ID="LN">440 </FONT><A NAME="440"></A>            <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'S'</FONT>:
<FONT ID="LN">441 </FONT><A NAME="441"></A>            <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'Z'</FONT>:
<FONT ID="LN">442 </FONT><A NAME="442"></A>                i += <FONT ID="IntegerLiteral">1</FONT>;
<FONT ID="LN">443 </FONT><A NAME="443"></A>                <FONT ID="Break">break</FONT>;
<FONT ID="LN">444 </FONT><A NAME="444"></A>            <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'['</FONT>:
<FONT ID="LN">445 </FONT><A NAME="445"></A>                <FONT ID="Break">break</FONT>;
<FONT ID="LN">446 </FONT><A NAME="446"></A>            <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'J'</FONT>:
<FONT ID="LN">447 </FONT><A NAME="447"></A>            <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'D'</FONT>:
<FONT ID="LN">448 </FONT><A NAME="448"></A>                i += <FONT ID="IntegerLiteral">2</FONT>;
<FONT ID="LN">449 </FONT><A NAME="449"></A>                <FONT ID="Break">break</FONT>;
<FONT ID="LN">450 </FONT><A NAME="450"></A>            <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'L'</FONT>:
<FONT ID="LN">451 </FONT><A NAME="451"></A>                <FONT ID="Int">int</FONT> k = argTypes.indexOf(<FONT ID="StringLiteral">";"</FONT>, j);
<FONT ID="LN">452 </FONT><A NAME="452"></A>                j = k;
<FONT ID="LN">453 </FONT><A NAME="453"></A>                i += <FONT ID="IntegerLiteral">1</FONT>;
<FONT ID="LN">454 </FONT><A NAME="454"></A>                <FONT ID="Break">break</FONT>;
<FONT ID="LN">455 </FONT><A NAME="455"></A>            }
<FONT ID="LN">456 </FONT><A NAME="456"></A>        }
<FONT ID="LN">457 </FONT><A NAME="457"></A>        <FONT ID="Return">return</FONT> i;
<FONT ID="LN">458 </FONT><A NAME="458"></A>    }
<FONT ID="LN">459 </FONT><A NAME="459"></A>
<FONT ID="LN">460 </FONT><A NAME="460"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">461 </FONT><A NAME="461"></A>     * Return true if the specified name is in the internal form of a fully
<FONT ID="LN">462 </FONT><A NAME="462"></A>     * qualified class or interface name [JVMS 4.3], false otherwise.
<FONT ID="LN">463 </FONT><A NAME="463"></A>     * 
<FONT ID="LN">464 </FONT><A NAME="464"></A>     * @param name
<FONT ID="LN">465 </FONT><A NAME="465"></A>     *            fully qualified class name in internal form.
<FONT ID="LN">466 </FONT><A NAME="466"></A>     * @return true if the specified name is in the internal form of a fully
<FONT ID="LN">467 </FONT><A NAME="467"></A>     *         qualified class or interface name, false otherwise.
<FONT ID="LN">468 </FONT><A NAME="468"></A>     */</FONT>
<FONT ID="LN">469 </FONT><A NAME="469"></A>
<FONT ID="LN">470 </FONT><A NAME="470"></A>    <FONT ID="Private">private</FONT> <FONT ID="Boolean">boolean</FONT> validInternalForm(String name) {
<FONT ID="LN">471 </FONT><A NAME="471"></A>        <FONT ID="If">if</FONT> ((name == <FONT ID="Null">null</FONT>) || name.equals(<FONT ID="StringLiteral">""</FONT>) || name.startsWith(<FONT ID="StringLiteral">"/"</FONT>)
<FONT ID="LN">472 </FONT><A NAME="472"></A>                || name.endsWith(<FONT ID="StringLiteral">"/"</FONT>)) {
<FONT ID="LN">473 </FONT><A NAME="473"></A>            <FONT ID="Return">return</FONT> <FONT ID="False">false</FONT>;
<FONT ID="LN">474 </FONT><A NAME="474"></A>        }
<FONT ID="LN">475 </FONT><A NAME="475"></A>        StringTokenizer t = <FONT ID="New">new</FONT> StringTokenizer(name, <FONT ID="StringLiteral">"/"</FONT>);
<FONT ID="LN">476 </FONT><A NAME="476"></A>        <FONT ID="While">while</FONT> (t.hasMoreTokens()) {
<FONT ID="LN">477 </FONT><A NAME="477"></A>            String s = t.nextToken();
<FONT ID="LN">478 </FONT><A NAME="478"></A>            <FONT ID="For">for</FONT> (<FONT ID="Int">int</FONT> i = <FONT ID="IntegerLiteral">0</FONT>; i &lt; s.length(); i++) {
<FONT ID="LN">479 </FONT><A NAME="479"></A>                <FONT ID="If">if</FONT> (i == <FONT ID="IntegerLiteral">0</FONT>) {
<FONT ID="LN">480 </FONT><A NAME="480"></A>                    <FONT ID="If">if</FONT> (!Character.isJavaIdentifierStart(s.charAt(i))) {
<FONT ID="LN">481 </FONT><A NAME="481"></A>                        <FONT ID="Return">return</FONT> <FONT ID="False">false</FONT>;
<FONT ID="LN">482 </FONT><A NAME="482"></A>                    }
<FONT ID="LN">483 </FONT><A NAME="483"></A>                } <FONT ID="Else">else</FONT> {
<FONT ID="LN">484 </FONT><A NAME="484"></A>                    <FONT ID="If">if</FONT> (!Character.isJavaIdentifierPart(s.charAt(i))) {
<FONT ID="LN">485 </FONT><A NAME="485"></A>                        <FONT ID="Return">return</FONT> <FONT ID="False">false</FONT>;
<FONT ID="LN">486 </FONT><A NAME="486"></A>                    }
<FONT ID="LN">487 </FONT><A NAME="487"></A>                }
<FONT ID="LN">488 </FONT><A NAME="488"></A>            }
<FONT ID="LN">489 </FONT><A NAME="489"></A>        }
<FONT ID="LN">490 </FONT><A NAME="490"></A>        <FONT ID="Return">return</FONT> <FONT ID="True">true</FONT>;
<FONT ID="LN">491 </FONT><A NAME="491"></A>    }
<FONT ID="LN">492 </FONT><A NAME="492"></A>
<FONT ID="LN">493 </FONT><A NAME="493"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">494 </FONT><A NAME="494"></A>     * Return true if the specified descriptor is a valid type descriptor [JVMS
<FONT ID="LN">495 </FONT><A NAME="495"></A>     * 4.4.2], false otherwise.
<FONT ID="LN">496 </FONT><A NAME="496"></A>     * 
<FONT ID="LN">497 </FONT><A NAME="497"></A>     * @param descriptor
<FONT ID="LN">498 </FONT><A NAME="498"></A>     *            type descriptor.
<FONT ID="LN">499 </FONT><A NAME="499"></A>     * @return true if the specified descriptor is a valid type descriptor,
<FONT ID="LN">500 </FONT><A NAME="500"></A>     *         false otherwise.
<FONT ID="LN">501 </FONT><A NAME="501"></A>     */</FONT>
<FONT ID="LN">502 </FONT><A NAME="502"></A>
<FONT ID="LN">503 </FONT><A NAME="503"></A>    <FONT ID="Private">private</FONT> <FONT ID="Boolean">boolean</FONT> validTypeDescriptor(String descriptor) {
<FONT ID="LN">504 </FONT><A NAME="504"></A>        <FONT ID="If">if</FONT> (descriptor != <FONT ID="Null">null</FONT>) {
<FONT ID="LN">505 </FONT><A NAME="505"></A>            <FONT ID="Try">try</FONT> {
<FONT ID="LN">506 </FONT><A NAME="506"></A>                <FONT ID="Char">char</FONT> c = descriptor.charAt(<FONT ID="IntegerLiteral">0</FONT>);
<FONT ID="LN">507 </FONT><A NAME="507"></A>                <FONT ID="Switch">switch</FONT> (c) {
<FONT ID="LN">508 </FONT><A NAME="508"></A>                <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'B'</FONT>:
<FONT ID="LN">509 </FONT><A NAME="509"></A>                <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'C'</FONT>:
<FONT ID="LN">510 </FONT><A NAME="510"></A>                <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'I'</FONT>:
<FONT ID="LN">511 </FONT><A NAME="511"></A>                <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'F'</FONT>:
<FONT ID="LN">512 </FONT><A NAME="512"></A>                <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'S'</FONT>:
<FONT ID="LN">513 </FONT><A NAME="513"></A>                <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'Z'</FONT>:
<FONT ID="LN">514 </FONT><A NAME="514"></A>                <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'J'</FONT>:
<FONT ID="LN">515 </FONT><A NAME="515"></A>                <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'D'</FONT>:
<FONT ID="LN">516 </FONT><A NAME="516"></A>                    <FONT ID="Return">return</FONT> (descriptor.length() == <FONT ID="IntegerLiteral">1</FONT>);
<FONT ID="LN">517 </FONT><A NAME="517"></A>                <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'L'</FONT>:
<FONT ID="LN">518 </FONT><A NAME="518"></A>                    <FONT ID="If">if</FONT> (descriptor.endsWith(<FONT ID="StringLiteral">";"</FONT>)) {
<FONT ID="LN">519 </FONT><A NAME="519"></A>                        <FONT ID="Return">return</FONT> validInternalForm(descriptor.substring(<FONT ID="IntegerLiteral">1</FONT>,
<FONT ID="LN">520 </FONT><A NAME="520"></A>                                descriptor.length() - <FONT ID="IntegerLiteral">1</FONT>));
<FONT ID="LN">521 </FONT><A NAME="521"></A>                    }
<FONT ID="LN">522 </FONT><A NAME="522"></A>                    <FONT ID="Return">return</FONT> <FONT ID="False">false</FONT>;
<FONT ID="LN">523 </FONT><A NAME="523"></A>                <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'['</FONT>:
<FONT ID="LN">524 </FONT><A NAME="524"></A>                    <FONT ID="Return">return</FONT> validTypeDescriptor(descriptor.substring(<FONT ID="IntegerLiteral">1</FONT>));
<FONT ID="LN">525 </FONT><A NAME="525"></A>                }
<FONT ID="LN">526 </FONT><A NAME="526"></A>            } <FONT ID="Catch">catch</FONT> (IndexOutOfBoundsException e) {
<FONT ID="LN">527 </FONT><A NAME="527"></A>                <FONT ID="Return">return</FONT> <FONT ID="False">false</FONT>;
<FONT ID="LN">528 </FONT><A NAME="528"></A>            }
<FONT ID="LN">529 </FONT><A NAME="529"></A>        }
<FONT ID="LN">530 </FONT><A NAME="530"></A>        <FONT ID="Return">return</FONT> <FONT ID="False">false</FONT>;
<FONT ID="LN">531 </FONT><A NAME="531"></A>    }
<FONT ID="LN">532 </FONT><A NAME="532"></A>
<FONT ID="LN">533 </FONT><A NAME="533"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">534 </FONT><A NAME="534"></A>     * Return true if the specified descriptor is a valid method descriptor
<FONT ID="LN">535 </FONT><A NAME="535"></A>     * [JVMS 4.4.3], false otherwise.
<FONT ID="LN">536 </FONT><A NAME="536"></A>     * 
<FONT ID="LN">537 </FONT><A NAME="537"></A>     * @param descriptor
<FONT ID="LN">538 </FONT><A NAME="538"></A>     *            method descriptor.
<FONT ID="LN">539 </FONT><A NAME="539"></A>     * @return true if the specified descriptor is a valid method descriptor,
<FONT ID="LN">540 </FONT><A NAME="540"></A>     *         false otherwise.
<FONT ID="LN">541 </FONT><A NAME="541"></A>     */</FONT>
<FONT ID="LN">542 </FONT><A NAME="542"></A>
<FONT ID="LN">543 </FONT><A NAME="543"></A>    <FONT ID="Private">private</FONT> <FONT ID="Boolean">boolean</FONT> validMethodDescriptor(String descriptor) {
<FONT ID="LN">544 </FONT><A NAME="544"></A>        <FONT ID="If">if</FONT> ((descriptor != <FONT ID="Null">null</FONT>) &amp;&amp; (descriptor.length() &gt; <FONT ID="IntegerLiteral">0</FONT>)) {
<FONT ID="LN">545 </FONT><A NAME="545"></A>            <FONT ID="Try">try</FONT> {
<FONT ID="LN">546 </FONT><A NAME="546"></A>                <FONT ID="SingleLineComment">// Extract types of arguments and the return type
<FONT ID="LN">547 </FONT><A NAME="547"></A></FONT>                <FONT ID="SingleLineComment">// from
<FONT ID="LN">548 </FONT><A NAME="548"></A></FONT>                <FONT ID="SingleLineComment">// the method descriptor
<FONT ID="LN">549 </FONT><A NAME="549"></A></FONT>                String argTypes = descriptor.substring(<FONT ID="IntegerLiteral">1</FONT>, descriptor
<FONT ID="LN">550 </FONT><A NAME="550"></A>                        .lastIndexOf(<FONT ID="StringLiteral">")"</FONT>));
<FONT ID="LN">551 </FONT><A NAME="551"></A>                String returnType = descriptor.substring(descriptor
<FONT ID="LN">552 </FONT><A NAME="552"></A>                        .lastIndexOf(<FONT ID="StringLiteral">")"</FONT>) + <FONT ID="IntegerLiteral">1</FONT>);
<FONT ID="LN">553 </FONT><A NAME="553"></A>
<FONT ID="LN">554 </FONT><A NAME="554"></A>                <FONT ID="SingleLineComment">// Validate argument type syntax
<FONT ID="LN">555 </FONT><A NAME="555"></A></FONT>                <FONT ID="If">if</FONT> (argTypes.endsWith(<FONT ID="StringLiteral">"["</FONT>)) {
<FONT ID="LN">556 </FONT><A NAME="556"></A>                    <FONT ID="Return">return</FONT> <FONT ID="False">false</FONT>;
<FONT ID="LN">557 </FONT><A NAME="557"></A>                }
<FONT ID="LN">558 </FONT><A NAME="558"></A>                <FONT ID="For">for</FONT> (<FONT ID="Int">int</FONT> i = <FONT ID="IntegerLiteral">0</FONT>; i &lt; argTypes.length(); i++) {
<FONT ID="LN">559 </FONT><A NAME="559"></A>                    <FONT ID="Char">char</FONT> c = argTypes.charAt(i);
<FONT ID="LN">560 </FONT><A NAME="560"></A>                    <FONT ID="Switch">switch</FONT> (c) {
<FONT ID="LN">561 </FONT><A NAME="561"></A>                    <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'B'</FONT>:
<FONT ID="LN">562 </FONT><A NAME="562"></A>                    <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'C'</FONT>:
<FONT ID="LN">563 </FONT><A NAME="563"></A>                    <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'I'</FONT>:
<FONT ID="LN">564 </FONT><A NAME="564"></A>                    <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'F'</FONT>:
<FONT ID="LN">565 </FONT><A NAME="565"></A>                    <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'S'</FONT>:
<FONT ID="LN">566 </FONT><A NAME="566"></A>                    <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'Z'</FONT>:
<FONT ID="LN">567 </FONT><A NAME="567"></A>                    <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'J'</FONT>:
<FONT ID="LN">568 </FONT><A NAME="568"></A>                    <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'D'</FONT>:
<FONT ID="LN">569 </FONT><A NAME="569"></A>                    <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'['</FONT>:
<FONT ID="LN">570 </FONT><A NAME="570"></A>                        <FONT ID="Break">break</FONT>;
<FONT ID="LN">571 </FONT><A NAME="571"></A>                    <FONT ID="Case">case</FONT> <FONT ID="CharacerLiteral">'L'</FONT>:
<FONT ID="LN">572 </FONT><A NAME="572"></A>                        <FONT ID="Int">int</FONT> j = argTypes.indexOf(<FONT ID="StringLiteral">";"</FONT>, i);
<FONT ID="LN">573 </FONT><A NAME="573"></A>                        String s = argTypes.substring(i, j + <FONT ID="IntegerLiteral">1</FONT>);
<FONT ID="LN">574 </FONT><A NAME="574"></A>                        i = j;
<FONT ID="LN">575 </FONT><A NAME="575"></A>                        <FONT ID="If">if</FONT> (!validTypeDescriptor(s)) {
<FONT ID="LN">576 </FONT><A NAME="576"></A>                            <FONT ID="Return">return</FONT> <FONT ID="False">false</FONT>;
<FONT ID="LN">577 </FONT><A NAME="577"></A>                        }
<FONT ID="LN">578 </FONT><A NAME="578"></A>                        <FONT ID="Break">break</FONT>;
<FONT ID="LN">579 </FONT><A NAME="579"></A>                    <FONT ID="Default">default</FONT>:
<FONT ID="LN">580 </FONT><A NAME="580"></A>                        <FONT ID="Return">return</FONT> <FONT ID="False">false</FONT>;
<FONT ID="LN">581 </FONT><A NAME="581"></A>                    }
<FONT ID="LN">582 </FONT><A NAME="582"></A>                }
<FONT ID="LN">583 </FONT><A NAME="583"></A>
<FONT ID="LN">584 </FONT><A NAME="584"></A>                <FONT ID="SingleLineComment">// Validate return type syntax
<FONT ID="LN">585 </FONT><A NAME="585"></A></FONT>                <FONT ID="Return">return</FONT> (returnType.equals(<FONT ID="StringLiteral">"V"</FONT>) || validTypeDescriptor(returnType));
<FONT ID="LN">586 </FONT><A NAME="586"></A>            } <FONT ID="Catch">catch</FONT> (IndexOutOfBoundsException e) {
<FONT ID="LN">587 </FONT><A NAME="587"></A>                <FONT ID="Return">return</FONT> <FONT ID="False">false</FONT>;
<FONT ID="LN">588 </FONT><A NAME="588"></A>            }
<FONT ID="LN">589 </FONT><A NAME="589"></A>        }
<FONT ID="LN">590 </FONT><A NAME="590"></A>        <FONT ID="Return">return</FONT> <FONT ID="False">false</FONT>;
<FONT ID="LN">591 </FONT><A NAME="591"></A>    }
<FONT ID="LN">592 </FONT><A NAME="592"></A>
<FONT ID="LN">593 </FONT><A NAME="593"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">594 </FONT><A NAME="594"></A>     * Return the instruction with the specified pc within the code array of the
<FONT ID="LN">595 </FONT><A NAME="595"></A>     * current method being added.
<FONT ID="LN">596 </FONT><A NAME="596"></A>     * 
<FONT ID="LN">597 </FONT><A NAME="597"></A>     * @param pc
<FONT ID="LN">598 </FONT><A NAME="598"></A>     *            pc of the instruction.
<FONT ID="LN">599 </FONT><A NAME="599"></A>     * @return the instruction with the specified pc, or null.
<FONT ID="LN">600 </FONT><A NAME="600"></A>     */</FONT>
<FONT ID="LN">601 </FONT><A NAME="601"></A>
<FONT ID="LN">602 </FONT><A NAME="602"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/CLInstruction.java.html">CLInstruction</A> instruction(<FONT ID="Int">int</FONT> pc) {
<FONT ID="LN">603 </FONT><A NAME="603"></A>        <FONT ID="For">for</FONT> (<FONT ID="Int">int</FONT> j = <FONT ID="IntegerLiteral">0</FONT>; j &lt; mCode.size(); j++) {
<FONT ID="LN">604 </FONT><A NAME="604"></A>            <A HREF="../jminusminus/CLInstruction.java.html">CLInstruction</A> i = mCode.get(j);
<FONT ID="LN">605 </FONT><A NAME="605"></A>            <FONT ID="If">if</FONT> (i.pc() == pc) {
<FONT ID="LN">606 </FONT><A NAME="606"></A>                <FONT ID="Return">return</FONT> i;
<FONT ID="LN">607 </FONT><A NAME="607"></A>            }
<FONT ID="LN">608 </FONT><A NAME="608"></A>        }
<FONT ID="LN">609 </FONT><A NAME="609"></A>        <FONT ID="Return">return</FONT> <FONT ID="Null">null</FONT>;
<FONT ID="LN">610 </FONT><A NAME="610"></A>    }
<FONT ID="LN">611 </FONT><A NAME="611"></A>
<FONT ID="LN">612 </FONT><A NAME="612"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">613 </FONT><A NAME="613"></A>     * Return the index of the instruction with the specified pc, within the
<FONT ID="LN">614 </FONT><A NAME="614"></A>     * code array of the current method being added.
<FONT ID="LN">615 </FONT><A NAME="615"></A>     * 
<FONT ID="LN">616 </FONT><A NAME="616"></A>     * @param pc
<FONT ID="LN">617 </FONT><A NAME="617"></A>     *            pc of the instruction.
<FONT ID="LN">618 </FONT><A NAME="618"></A>     * @return index of the instruction with the specified pc.
<FONT ID="LN">619 </FONT><A NAME="619"></A>     */</FONT>
<FONT ID="LN">620 </FONT><A NAME="620"></A>
<FONT ID="LN">621 </FONT><A NAME="621"></A>    <FONT ID="Private">private</FONT> <FONT ID="Int">int</FONT> instructionIndex(<FONT ID="Int">int</FONT> pc) {
<FONT ID="LN">622 </FONT><A NAME="622"></A>        <FONT ID="Int">int</FONT> j = <FONT ID="IntegerLiteral">0</FONT>;
<FONT ID="LN">623 </FONT><A NAME="623"></A>        <FONT ID="For">for</FONT> (; j &lt; mCode.size(); j++) {
<FONT ID="LN">624 </FONT><A NAME="624"></A>            <A HREF="../jminusminus/CLInstruction.java.html">CLInstruction</A> i = mCode.get(j);
<FONT ID="LN">625 </FONT><A NAME="625"></A>            <FONT ID="If">if</FONT> (i.pc() == pc) {
<FONT ID="LN">626 </FONT><A NAME="626"></A>                <FONT ID="Return">return</FONT> j;
<FONT ID="LN">627 </FONT><A NAME="627"></A>            }
<FONT ID="LN">628 </FONT><A NAME="628"></A>        }
<FONT ID="LN">629 </FONT><A NAME="629"></A>        <FONT ID="Return">return</FONT> j;
<FONT ID="LN">630 </FONT><A NAME="630"></A>    }
<FONT ID="LN">631 </FONT><A NAME="631"></A>
<FONT ID="LN">632 </FONT><A NAME="632"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">633 </FONT><A NAME="633"></A>     * Compute the maximum depth of the operand stack for the method last added,
<FONT ID="LN">634 </FONT><A NAME="634"></A>     * and return the value.
<FONT ID="LN">635 </FONT><A NAME="635"></A>     * 
<FONT ID="LN">636 </FONT><A NAME="636"></A>     * @return maximum depth of operand stack.
<FONT ID="LN">637 </FONT><A NAME="637"></A>     */</FONT>
<FONT ID="LN">638 </FONT><A NAME="638"></A>
<FONT ID="LN">639 </FONT><A NAME="639"></A>    <FONT ID="Private">private</FONT> <FONT ID="Int">int</FONT> stackDepth() {
<FONT ID="LN">640 </FONT><A NAME="640"></A>        CLBranchStack branchTargets = <FONT ID="New">new</FONT> CLBranchStack();
<FONT ID="LN">641 </FONT><A NAME="641"></A>        <FONT ID="For">for</FONT> (<FONT ID="Int">int</FONT> i = <FONT ID="IntegerLiteral">0</FONT>; i &lt; mExceptionHandlers.size(); i++) {
<FONT ID="LN">642 </FONT><A NAME="642"></A>            CLException e = mExceptionHandlers.get(i);
<FONT ID="LN">643 </FONT><A NAME="643"></A>            <A HREF="../jminusminus/CLInstruction.java.html">CLInstruction</A> h = instruction(e.handlerPC);
<FONT ID="LN">644 </FONT><A NAME="644"></A>            <FONT ID="If">if</FONT> (h != <FONT ID="Null">null</FONT>) {
<FONT ID="LN">645 </FONT><A NAME="645"></A>                <FONT ID="SingleLineComment">// 1 because the exception that is thrown is
<FONT ID="LN">646 </FONT><A NAME="646"></A></FONT>                <FONT ID="SingleLineComment">// pushed
<FONT ID="LN">647 </FONT><A NAME="647"></A></FONT>                <FONT ID="SingleLineComment">// on top of the operand stack
<FONT ID="LN">648 </FONT><A NAME="648"></A></FONT>                branchTargets.push(h, <FONT ID="IntegerLiteral">1</FONT>);
<FONT ID="LN">649 </FONT><A NAME="649"></A>            }
<FONT ID="LN">650 </FONT><A NAME="650"></A>        }
<FONT ID="LN">651 </FONT><A NAME="651"></A>        <FONT ID="Int">int</FONT> stackDepth = <FONT ID="IntegerLiteral">0</FONT>, maxStackDepth = <FONT ID="IntegerLiteral">0</FONT>, c = <FONT ID="IntegerLiteral">0</FONT>;
<FONT ID="LN">652 </FONT><A NAME="652"></A>        <A HREF="../jminusminus/CLInstruction.java.html">CLInstruction</A> instr = (mCode.size() == <FONT ID="IntegerLiteral">0</FONT>) ? <FONT ID="Null">null</FONT> : mCode.get(c);
<FONT ID="LN">653 </FONT><A NAME="653"></A>        <FONT ID="While">while</FONT> (instr != <FONT ID="Null">null</FONT>) {
<FONT ID="LN">654 </FONT><A NAME="654"></A>            <FONT ID="Int">int</FONT> opcode = instr.opcode();
<FONT ID="LN">655 </FONT><A NAME="655"></A>            <FONT ID="Int">int</FONT> stackUnits = instr.stackUnits();
<FONT ID="LN">656 </FONT><A NAME="656"></A>            <FONT ID="If">if</FONT> (stackUnits == EMPTY_STACK) {
<FONT ID="LN">657 </FONT><A NAME="657"></A>                stackDepth = <FONT ID="IntegerLiteral">0</FONT>;
<FONT ID="LN">658 </FONT><A NAME="658"></A>            } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (stackUnits == UNIT_SIZE_STACK) {
<FONT ID="LN">659 </FONT><A NAME="659"></A>                stackDepth = <FONT ID="IntegerLiteral">1</FONT>;
<FONT ID="LN">660 </FONT><A NAME="660"></A>            } <FONT ID="Else">else</FONT> {
<FONT ID="LN">661 </FONT><A NAME="661"></A>                stackDepth += stackUnits;
<FONT ID="LN">662 </FONT><A NAME="662"></A>            }
<FONT ID="LN">663 </FONT><A NAME="663"></A>            <FONT ID="If">if</FONT> (stackDepth &gt; maxStackDepth) {
<FONT ID="LN">664 </FONT><A NAME="664"></A>                maxStackDepth = stackDepth;
<FONT ID="LN">665 </FONT><A NAME="665"></A>            }
<FONT ID="LN">666 </FONT><A NAME="666"></A>
<FONT ID="LN">667 </FONT><A NAME="667"></A>            <FONT ID="SingleLineComment">// For tracing purposes
<FONT ID="LN">668 </FONT><A NAME="668"></A></FONT>            <FONT ID="SingleLineComment">// System.out.println( instr.mnemonic() + ", " +
<FONT ID="LN">669 </FONT><A NAME="669"></A></FONT>            <FONT ID="SingleLineComment">// stackUnits + ", " +
<FONT ID="LN">670 </FONT><A NAME="670"></A></FONT>            <FONT ID="SingleLineComment">// stackDepth + ", " + maxStackDepth );
<FONT ID="LN">671 </FONT><A NAME="671"></A></FONT>
<FONT ID="LN">672 </FONT><A NAME="672"></A>            <FONT ID="If">if</FONT> (instr <FONT ID="InstanceOf">instanceof</FONT> CLFlowControlInstruction) {
<FONT ID="LN">673 </FONT><A NAME="673"></A>                CLFlowControlInstruction b = (CLFlowControlInstruction) instr;
<FONT ID="LN">674 </FONT><A NAME="674"></A>                <FONT ID="Int">int</FONT> jumpToIndex = b.pc() + b.jumpToOffset();
<FONT ID="LN">675 </FONT><A NAME="675"></A>                <A HREF="../jminusminus/CLInstruction.java.html">CLInstruction</A> instrAt = <FONT ID="Null">null</FONT>;
<FONT ID="LN">676 </FONT><A NAME="676"></A>                <FONT ID="Switch">switch</FONT> (opcode) {
<FONT ID="LN">677 </FONT><A NAME="677"></A>                <FONT ID="Case">case</FONT> JSR:
<FONT ID="LN">678 </FONT><A NAME="678"></A>                <FONT ID="Case">case</FONT> JSR_W:
<FONT ID="LN">679 </FONT><A NAME="679"></A>                <FONT ID="Case">case</FONT> RET:
<FONT ID="LN">680 </FONT><A NAME="680"></A>                    instr = <FONT ID="Null">null</FONT>;
<FONT ID="LN">681 </FONT><A NAME="681"></A>                    <FONT ID="Break">break</FONT>;
<FONT ID="LN">682 </FONT><A NAME="682"></A>                <FONT ID="Case">case</FONT> GOTO:
<FONT ID="LN">683 </FONT><A NAME="683"></A>                <FONT ID="Case">case</FONT> GOTO_W:
<FONT ID="LN">684 </FONT><A NAME="684"></A>                    instr = <FONT ID="Null">null</FONT>;
<FONT ID="LN">685 </FONT><A NAME="685"></A>                <FONT ID="Default">default</FONT>:
<FONT ID="LN">686 </FONT><A NAME="686"></A>                    instrAt = instruction(jumpToIndex);
<FONT ID="LN">687 </FONT><A NAME="687"></A>                    <FONT ID="If">if</FONT> (instrAt != <FONT ID="Null">null</FONT>) {
<FONT ID="LN">688 </FONT><A NAME="688"></A>                        branchTargets.push(instrAt, stackDepth);
<FONT ID="LN">689 </FONT><A NAME="689"></A>                    }
<FONT ID="LN">690 </FONT><A NAME="690"></A>                }
<FONT ID="LN">691 </FONT><A NAME="691"></A>            } <FONT ID="Else">else</FONT> {
<FONT ID="LN">692 </FONT><A NAME="692"></A>                <FONT ID="If">if</FONT> ((opcode == ATHROW)
<FONT ID="LN">693 </FONT><A NAME="693"></A>                        || ((opcode &gt;= IRETURN) &amp;&amp; (opcode &lt;= RETURN))) {
<FONT ID="LN">694 </FONT><A NAME="694"></A>                    instr = <FONT ID="Null">null</FONT>;
<FONT ID="LN">695 </FONT><A NAME="695"></A>                }
<FONT ID="LN">696 </FONT><A NAME="696"></A>            }
<FONT ID="LN">697 </FONT><A NAME="697"></A>            <FONT ID="If">if</FONT> (instr != <FONT ID="Null">null</FONT>) {
<FONT ID="LN">698 </FONT><A NAME="698"></A>                c++;
<FONT ID="LN">699 </FONT><A NAME="699"></A>                instr = (c &gt;= mCode.size()) ? <FONT ID="Null">null</FONT> : mCode.get(c);
<FONT ID="LN">700 </FONT><A NAME="700"></A>            }
<FONT ID="LN">701 </FONT><A NAME="701"></A>            <FONT ID="If">if</FONT> (instr == <FONT ID="Null">null</FONT>) {
<FONT ID="LN">702 </FONT><A NAME="702"></A>                CLBranchTarget bt = branchTargets.pop();
<FONT ID="LN">703 </FONT><A NAME="703"></A>                <FONT ID="If">if</FONT> (bt != <FONT ID="Null">null</FONT>) {
<FONT ID="LN">704 </FONT><A NAME="704"></A>                    instr = bt.target;
<FONT ID="LN">705 </FONT><A NAME="705"></A>                    stackDepth = bt.stackDepth;
<FONT ID="LN">706 </FONT><A NAME="706"></A>                    c = instructionIndex(instr.pc());
<FONT ID="LN">707 </FONT><A NAME="707"></A>                }
<FONT ID="LN">708 </FONT><A NAME="708"></A>            }
<FONT ID="LN">709 </FONT><A NAME="709"></A>        }
<FONT ID="LN">710 </FONT><A NAME="710"></A>        <FONT ID="Return">return</FONT> maxStackDepth;
<FONT ID="LN">711 </FONT><A NAME="711"></A>    }
<FONT ID="LN">712 </FONT><A NAME="712"></A>
<FONT ID="LN">713 </FONT><A NAME="713"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">714 </FONT><A NAME="714"></A>     * Add LDC (LDC_W if index is wide) instruction.
<FONT ID="LN">715 </FONT><A NAME="715"></A>     * 
<FONT ID="LN">716 </FONT><A NAME="716"></A>     * @param index
<FONT ID="LN">717 </FONT><A NAME="717"></A>     *            index into the constant pool, the item at which is a
<FONT ID="LN">718 </FONT><A NAME="718"></A>     *            ConstantIntegerInfo, ConstantFloatInfo or ConstantStringInfo
<FONT ID="LN">719 </FONT><A NAME="719"></A>     *            instance. If index is wide, i.e., greater than 255, LDC_W
<FONT ID="LN">720 </FONT><A NAME="720"></A>     *            version of the instruction is added.
<FONT ID="LN">721 </FONT><A NAME="721"></A>     */</FONT>
<FONT ID="LN">722 </FONT><A NAME="722"></A>
<FONT ID="LN">723 </FONT><A NAME="723"></A>    <FONT ID="Private">private</FONT> <FONT ID="Void">void</FONT> ldcInstruction(<FONT ID="Int">int</FONT> index) {
<FONT ID="LN">724 </FONT><A NAME="724"></A>        CLLoadStoreInstruction instr = <FONT ID="Null">null</FONT>;
<FONT ID="LN">725 </FONT><A NAME="725"></A>        <FONT ID="If">if</FONT> (index &lt;= <FONT ID="IntegerLiteral">255</FONT>) {
<FONT ID="LN">726 </FONT><A NAME="726"></A>            instr = <FONT ID="New">new</FONT> CLLoadStoreInstruction(LDC, mPC++, index);
<FONT ID="LN">727 </FONT><A NAME="727"></A>        } <FONT ID="Else">else</FONT> {
<FONT ID="LN">728 </FONT><A NAME="728"></A>            instr = <FONT ID="New">new</FONT> CLLoadStoreInstruction(LDC_W, mPC++, index);
<FONT ID="LN">729 </FONT><A NAME="729"></A>        }
<FONT ID="LN">730 </FONT><A NAME="730"></A>        mPC += instr.operandCount();
<FONT ID="LN">731 </FONT><A NAME="731"></A>        mCode.add(instr);
<FONT ID="LN">732 </FONT><A NAME="732"></A>        mInstructionAfterLabel = <FONT ID="True">true</FONT>;
<FONT ID="LN">733 </FONT><A NAME="733"></A>    }
<FONT ID="LN">734 </FONT><A NAME="734"></A>
<FONT ID="LN">735 </FONT><A NAME="735"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">736 </FONT><A NAME="736"></A>     * Add LDC2_W instruction -- used for long and double constants. Note that
<FONT ID="LN">737 </FONT><A NAME="737"></A>     * only a wide-index version of LDC2_W instruction exists.
<FONT ID="LN">738 </FONT><A NAME="738"></A>     * 
<FONT ID="LN">739 </FONT><A NAME="739"></A>     * @param index
<FONT ID="LN">740 </FONT><A NAME="740"></A>     *            index into the constant pool, the item at which is a
<FONT ID="LN">741 </FONT><A NAME="741"></A>     *            ConstantLongInfo or ConstantDoubleInfo item.
<FONT ID="LN">742 </FONT><A NAME="742"></A>     */</FONT>
<FONT ID="LN">743 </FONT><A NAME="743"></A>
<FONT ID="LN">744 </FONT><A NAME="744"></A>    <FONT ID="Private">private</FONT> <FONT ID="Void">void</FONT> ldc2wInstruction(<FONT ID="Int">int</FONT> index) {
<FONT ID="LN">745 </FONT><A NAME="745"></A>        CLLoadStoreInstruction instr = <FONT ID="New">new</FONT> CLLoadStoreInstruction(LDC2_W,
<FONT ID="LN">746 </FONT><A NAME="746"></A>                mPC++, index);
<FONT ID="LN">747 </FONT><A NAME="747"></A>        mPC += instr.operandCount();
<FONT ID="LN">748 </FONT><A NAME="748"></A>        mCode.add(instr);
<FONT ID="LN">749 </FONT><A NAME="749"></A>        mInstructionAfterLabel = <FONT ID="True">true</FONT>;
<FONT ID="LN">750 </FONT><A NAME="750"></A>    }
<FONT ID="LN">751 </FONT><A NAME="751"></A>
<FONT ID="LN">752 </FONT><A NAME="752"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">753 </FONT><A NAME="753"></A>     * Construct and return a ConstantValue attribute given the constant value
<FONT ID="LN">754 </FONT><A NAME="754"></A>     * index.
<FONT ID="LN">755 </FONT><A NAME="755"></A>     * 
<FONT ID="LN">756 </FONT><A NAME="756"></A>     * @param c
<FONT ID="LN">757 </FONT><A NAME="757"></A>     *            index into the constant pool, the item at which is the
<FONT ID="LN">758 </FONT><A NAME="758"></A>     *            constant value.
<FONT ID="LN">759 </FONT><A NAME="759"></A>     * @return a ConstantValue attribute.
<FONT ID="LN">760 </FONT><A NAME="760"></A>     */</FONT>
<FONT ID="LN">761 </FONT><A NAME="761"></A>
<FONT ID="LN">762 </FONT><A NAME="762"></A>    <FONT ID="Private">private</FONT> CLConstantValueAttribute constantValueAttribute(<FONT ID="Int">int</FONT> c) {
<FONT ID="LN">763 </FONT><A NAME="763"></A>        <FONT ID="Int">int</FONT> attributeNameIndex = constantPool
<FONT ID="LN">764 </FONT><A NAME="764"></A>                .constantUtf8Info(ATT_CONSTANT_VALUE);
<FONT ID="LN">765 </FONT><A NAME="765"></A>        <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> CLConstantValueAttribute(attributeNameIndex, <FONT ID="IntegerLiteral">2</FONT>, c);
<FONT ID="LN">766 </FONT><A NAME="766"></A>    }
<FONT ID="LN">767 </FONT><A NAME="767"></A>
<FONT ID="LN">768 </FONT><A NAME="768"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">769 </FONT><A NAME="769"></A>     * Construct and return a Code attribute given the list of bytes that make
<FONT ID="LN">770 </FONT><A NAME="770"></A>     * up the instructions and their operands, exception table, maximum depth of
<FONT ID="LN">771 </FONT><A NAME="771"></A>     * operand stack, and maximum number of local variables.
<FONT ID="LN">772 </FONT><A NAME="772"></A>     * 
<FONT ID="LN">773 </FONT><A NAME="773"></A>     * @param byteCode
<FONT ID="LN">774 </FONT><A NAME="774"></A>     *            list of bytes that make up the instructions and their
<FONT ID="LN">775 </FONT><A NAME="775"></A>     *            operands.
<FONT ID="LN">776 </FONT><A NAME="776"></A>     * @param exceptionTable
<FONT ID="LN">777 </FONT><A NAME="777"></A>     *            exception table.
<FONT ID="LN">778 </FONT><A NAME="778"></A>     * @param stackDepth
<FONT ID="LN">779 </FONT><A NAME="779"></A>     *            maximum depth of operand stack.
<FONT ID="LN">780 </FONT><A NAME="780"></A>     * @param maxLocals
<FONT ID="LN">781 </FONT><A NAME="781"></A>     *            maximum number of local variables.
<FONT ID="LN">782 </FONT><A NAME="782"></A>     * @return a Code attribute.
<FONT ID="LN">783 </FONT><A NAME="783"></A>     */</FONT>
<FONT ID="LN">784 </FONT><A NAME="784"></A>
<FONT ID="LN">785 </FONT><A NAME="785"></A>    <FONT ID="Private">private</FONT> CLCodeAttribute codeAttribute(ArrayList&lt;Integer&gt; byteCode,
<FONT ID="LN">786 </FONT><A NAME="786"></A>            ArrayList&lt;CLExceptionInfo&gt; exceptionTable, <FONT ID="Int">int</FONT> stackDepth,
<FONT ID="LN">787 </FONT><A NAME="787"></A>            <FONT ID="Int">int</FONT> maxLocals) {
<FONT ID="LN">788 </FONT><A NAME="788"></A>        <FONT ID="Int">int</FONT> codeLength = byteCode.size();
<FONT ID="LN">789 </FONT><A NAME="789"></A>        <FONT ID="Int">int</FONT> attributeNameIndex = constantPool.constantUtf8Info(ATT_CODE);
<FONT ID="LN">790 </FONT><A NAME="790"></A>        <FONT ID="Int">int</FONT> attributeLength = codeLength + <FONT ID="IntegerLiteral">8</FONT> * exceptionTable.size() + <FONT ID="IntegerLiteral">12</FONT>;
<FONT ID="LN">791 </FONT><A NAME="791"></A>        <FONT ID="For">for</FONT> (<FONT ID="Int">int</FONT> i = <FONT ID="IntegerLiteral">0</FONT>; i &lt; mCodeAttributes.size(); i++) {
<FONT ID="LN">792 </FONT><A NAME="792"></A>            attributeLength += <FONT ID="IntegerLiteral">6</FONT> + mCodeAttributes.get(i).attributeLength;
<FONT ID="LN">793 </FONT><A NAME="793"></A>        }
<FONT ID="LN">794 </FONT><A NAME="794"></A>        <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> CLCodeAttribute(attributeNameIndex, attributeLength,
<FONT ID="LN">795 </FONT><A NAME="795"></A>                stackDepth, maxLocals, (<FONT ID="Long">long</FONT>) codeLength, byteCode,
<FONT ID="LN">796 </FONT><A NAME="796"></A>                exceptionTable.size(), exceptionTable, mCodeAttributes.size(),
<FONT ID="LN">797 </FONT><A NAME="797"></A>                mCodeAttributes);
<FONT ID="LN">798 </FONT><A NAME="798"></A>    }
<FONT ID="LN">799 </FONT><A NAME="799"></A>
<FONT ID="LN">800 </FONT><A NAME="800"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">801 </FONT><A NAME="801"></A>     * Construct and return an ExceptionsAttribute given the list of exceptions.
<FONT ID="LN">802 </FONT><A NAME="802"></A>     * 
<FONT ID="LN">803 </FONT><A NAME="803"></A>     * @param exceptions
<FONT ID="LN">804 </FONT><A NAME="804"></A>     *            list of exceptions in internal form.
<FONT ID="LN">805 </FONT><A NAME="805"></A>     * @return an Exceptions attribute.
<FONT ID="LN">806 </FONT><A NAME="806"></A>     */</FONT>
<FONT ID="LN">807 </FONT><A NAME="807"></A>
<FONT ID="LN">808 </FONT><A NAME="808"></A>    <FONT ID="Private">private</FONT> CLExceptionsAttribute exceptionsAttribute(
<FONT ID="LN">809 </FONT><A NAME="809"></A>            ArrayList&lt;String&gt; exceptions) {
<FONT ID="LN">810 </FONT><A NAME="810"></A>        <FONT ID="Int">int</FONT> attributeNameIndex = constantPool.constantUtf8Info(ATT_EXCEPTIONS);
<FONT ID="LN">811 </FONT><A NAME="811"></A>        ArrayList&lt;Integer&gt; exceptionIndexTable = <FONT ID="New">new</FONT> ArrayList&lt;Integer&gt;();
<FONT ID="LN">812 </FONT><A NAME="812"></A>        <FONT ID="For">for</FONT> (<FONT ID="Int">int</FONT> i = <FONT ID="IntegerLiteral">0</FONT>; i &lt; exceptions.size(); i++) {
<FONT ID="LN">813 </FONT><A NAME="813"></A>            String e = exceptions.get(i);
<FONT ID="LN">814 </FONT><A NAME="814"></A>            exceptionIndexTable.add(<FONT ID="New">new</FONT> Integer(constantPool
<FONT ID="LN">815 </FONT><A NAME="815"></A>                    .constantClassInfo(e)));
<FONT ID="LN">816 </FONT><A NAME="816"></A>        }
<FONT ID="LN">817 </FONT><A NAME="817"></A>        <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> CLExceptionsAttribute(attributeNameIndex,
<FONT ID="LN">818 </FONT><A NAME="818"></A>                exceptionIndexTable.size() * <FONT ID="IntegerLiteral">2</FONT> + <FONT ID="IntegerLiteral">2</FONT>, exceptionIndexTable.size(),
<FONT ID="LN">819 </FONT><A NAME="819"></A>                exceptionIndexTable);
<FONT ID="LN">820 </FONT><A NAME="820"></A>    }
<FONT ID="LN">821 </FONT><A NAME="821"></A>
<FONT ID="LN">822 </FONT><A NAME="822"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">823 </FONT><A NAME="823"></A>     * Construct and return InnerClasses attribute.
<FONT ID="LN">824 </FONT><A NAME="824"></A>     * 
<FONT ID="LN">825 </FONT><A NAME="825"></A>     * @return an InnerClasses attribute.
<FONT ID="LN">826 </FONT><A NAME="826"></A>     */</FONT>
<FONT ID="LN">827 </FONT><A NAME="827"></A>
<FONT ID="LN">828 </FONT><A NAME="828"></A>    <FONT ID="Private">private</FONT> CLInnerClassesAttribute innerClassesAttribute() {
<FONT ID="LN">829 </FONT><A NAME="829"></A>        <FONT ID="Int">int</FONT> attributeNameIndex = constantPool
<FONT ID="LN">830 </FONT><A NAME="830"></A>                .constantUtf8Info(ATT_INNER_CLASSES);
<FONT ID="LN">831 </FONT><A NAME="831"></A>        <FONT ID="Long">long</FONT> attributeLength = innerClasses.size() * <FONT ID="IntegerLiteral">8</FONT> + <FONT ID="IntegerLiteral">2</FONT>;
<FONT ID="LN">832 </FONT><A NAME="832"></A>        <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> CLInnerClassesAttribute(attributeNameIndex, attributeLength,
<FONT ID="LN">833 </FONT><A NAME="833"></A>                innerClasses.size(), innerClasses);
<FONT ID="LN">834 </FONT><A NAME="834"></A>    }
<FONT ID="LN">835 </FONT><A NAME="835"></A>
<FONT ID="LN">836 </FONT><A NAME="836"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">837 </FONT><A NAME="837"></A>     * Construct and return a Synthetic attribute.
<FONT ID="LN">838 </FONT><A NAME="838"></A>     * 
<FONT ID="LN">839 </FONT><A NAME="839"></A>     * @param a
<FONT ID="LN">840 </FONT><A NAME="840"></A>     *            Synthetic attribute.
<FONT ID="LN">841 </FONT><A NAME="841"></A>     */</FONT>
<FONT ID="LN">842 </FONT><A NAME="842"></A>
<FONT ID="LN">843 </FONT><A NAME="843"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/CLAttributeInfo.java.html">CLAttributeInfo</A> syntheticAttribute() {
<FONT ID="LN">844 </FONT><A NAME="844"></A>        <FONT ID="Int">int</FONT> attributeNameIndex = constantPool.constantUtf8Info(ATT_SYNTHETIC);
<FONT ID="LN">845 </FONT><A NAME="845"></A>        <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> CLSyntheticAttribute(attributeNameIndex, <FONT ID="IntegerLiteral">0</FONT>);
<FONT ID="LN">846 </FONT><A NAME="846"></A>    }
<FONT ID="LN">847 </FONT><A NAME="847"></A>
<FONT ID="LN">848 </FONT><A NAME="848"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">849 </FONT><A NAME="849"></A>     * Used to report an error if the opcode used for adding an instruction is
<FONT ID="LN">850 </FONT><A NAME="850"></A>     * invalid, or if an incorrect method from CLEmitter is used to add the
<FONT ID="LN">851 </FONT><A NAME="851"></A>     * opcode.
<FONT ID="LN">852 </FONT><A NAME="852"></A>     * 
<FONT ID="LN">853 </FONT><A NAME="853"></A>     * @param opcode
<FONT ID="LN">854 </FONT><A NAME="854"></A>     *            opcode of the instruction.
<FONT ID="LN">855 </FONT><A NAME="855"></A>     */</FONT>
<FONT ID="LN">856 </FONT><A NAME="856"></A>
<FONT ID="LN">857 </FONT><A NAME="857"></A>    <FONT ID="Private">private</FONT> <FONT ID="Void">void</FONT> reportOpcodeError(<FONT ID="Int">int</FONT> opcode) {
<FONT ID="LN">858 </FONT><A NAME="858"></A>        <FONT ID="If">if</FONT> (!CLInstruction.isValid(opcode)) {
<FONT ID="LN">859 </FONT><A NAME="859"></A>            reportEmitterError(<FONT ID="StringLiteral">"%s: Invalid opcode '%d'"</FONT>, eCurrentMethod,
<FONT ID="LN">860 </FONT><A NAME="860"></A>                    opcode);
<FONT ID="LN">861 </FONT><A NAME="861"></A>        } <FONT ID="Else">else</FONT> {
<FONT ID="LN">862 </FONT><A NAME="862"></A>            reportEmitterError(
<FONT ID="LN">863 </FONT><A NAME="863"></A>                    <FONT ID="StringLiteral">"%s: Incorrect method used to add instruction '%s'"</FONT>,
<FONT ID="LN">864 </FONT><A NAME="864"></A>                    eCurrentMethod,
<FONT ID="LN">865 </FONT><A NAME="865"></A>                    CLInstruction.instructionInfo[opcode].mnemonic);
<FONT ID="LN">866 </FONT><A NAME="866"></A>        }
<FONT ID="LN">867 </FONT><A NAME="867"></A>    }
<FONT ID="LN">868 </FONT><A NAME="868"></A>
<FONT ID="LN">869 </FONT><A NAME="869"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">870 </FONT><A NAME="870"></A>     * Report any error that occurs while creating/writing the class, to STDERR.
<FONT ID="LN">871 </FONT><A NAME="871"></A>     * 
<FONT ID="LN">872 </FONT><A NAME="872"></A>     * @param message
<FONT ID="LN">873 </FONT><A NAME="873"></A>     *            message identifying the error.
<FONT ID="LN">874 </FONT><A NAME="874"></A>     * @param args
<FONT ID="LN">875 </FONT><A NAME="875"></A>     *            related values.
<FONT ID="LN">876 </FONT><A NAME="876"></A>     */</FONT>
<FONT ID="LN">877 </FONT><A NAME="877"></A>
<FONT ID="LN">878 </FONT><A NAME="878"></A>    <FONT ID="Private">private</FONT> <FONT ID="Void">void</FONT> reportEmitterError(String message, Object... args) {
<FONT ID="LN">879 </FONT><A NAME="879"></A>        System.err.printf(message, args);
<FONT ID="LN">880 </FONT><A NAME="880"></A>        System.err.println();
<FONT ID="LN">881 </FONT><A NAME="881"></A>        errorHasOccurred = <FONT ID="True">true</FONT>;
<FONT ID="LN">882 </FONT><A NAME="882"></A>    }
<FONT ID="LN">883 </FONT><A NAME="883"></A>
<FONT ID="LN">884 </FONT><A NAME="884"></A>    <FONT ID="SingleLineComment">// /////////////////////////////////////////////////////
<FONT ID="LN">885 </FONT><A NAME="885"></A></FONT>    <FONT ID="SingleLineComment">// CLEmitter proper begins here
<FONT ID="LN">886 </FONT><A NAME="886"></A></FONT>    <FONT ID="SingleLineComment">// /////////////////////////////////////////////////////
<FONT ID="LN">887 </FONT><A NAME="887"></A></FONT>
<FONT ID="LN">888 </FONT><A NAME="888"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">889 </FONT><A NAME="889"></A>     * Construct a CLEmitter instance.
<FONT ID="LN">890 </FONT><A NAME="890"></A>     * 
<FONT ID="LN">891 </FONT><A NAME="891"></A>     * @param toFile
<FONT ID="LN">892 </FONT><A NAME="892"></A>     *            if true, the in-memory representation of the class file will
<FONT ID="LN">893 </FONT><A NAME="893"></A>     *            be written to the file system. Otherwise, it won't be saved as
<FONT ID="LN">894 </FONT><A NAME="894"></A>     *            a file.
<FONT ID="LN">895 </FONT><A NAME="895"></A>     */</FONT>
<FONT ID="LN">896 </FONT><A NAME="896"></A>
<FONT ID="LN">897 </FONT><A NAME="897"></A>    <FONT ID="Public">public</FONT> CLEmitter(<FONT ID="Boolean">boolean</FONT> toFile) {
<FONT ID="LN">898 </FONT><A NAME="898"></A>        destDir = <FONT ID="StringLiteral">"."</FONT>;
<FONT ID="LN">899 </FONT><A NAME="899"></A>        <FONT ID="This">this</FONT>.toFile = toFile;
<FONT ID="LN">900 </FONT><A NAME="900"></A>    }
<FONT ID="LN">901 </FONT><A NAME="901"></A>
<FONT ID="LN">902 </FONT><A NAME="902"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">903 </FONT><A NAME="903"></A>     * Set the destination directory for the class file to the specified value.
<FONT ID="LN">904 </FONT><A NAME="904"></A>     * 
<FONT ID="LN">905 </FONT><A NAME="905"></A>     * @param destDir
<FONT ID="LN">906 </FONT><A NAME="906"></A>     *            destination directory.
<FONT ID="LN">907 </FONT><A NAME="907"></A>     */</FONT>
<FONT ID="LN">908 </FONT><A NAME="908"></A>
<FONT ID="LN">909 </FONT><A NAME="909"></A>    <FONT ID="Public">public</FONT> <FONT ID="Void">void</FONT> destinationDir(String destDir) {
<FONT ID="LN">910 </FONT><A NAME="910"></A>        <FONT ID="This">this</FONT>.destDir = destDir;
<FONT ID="LN">911 </FONT><A NAME="911"></A>    }
<FONT ID="LN">912 </FONT><A NAME="912"></A>
<FONT ID="LN">913 </FONT><A NAME="913"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">914 </FONT><A NAME="914"></A>     * Has an emitter error occurred up to now?
<FONT ID="LN">915 </FONT><A NAME="915"></A>     * 
<FONT ID="LN">916 </FONT><A NAME="916"></A>     * @return true or false.
<FONT ID="LN">917 </FONT><A NAME="917"></A>     */</FONT>
<FONT ID="LN">918 </FONT><A NAME="918"></A>
<FONT ID="LN">919 </FONT><A NAME="919"></A>    <FONT ID="Public">public</FONT> <FONT ID="Boolean">boolean</FONT> errorHasOccurred() {
<FONT ID="LN">920 </FONT><A NAME="920"></A>        <FONT ID="Return">return</FONT> errorHasOccurred;
<FONT ID="LN">921 </FONT><A NAME="921"></A>    }
<FONT ID="LN">922 </FONT><A NAME="922"></A>
<FONT ID="LN">923 </FONT><A NAME="923"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">924 </FONT><A NAME="924"></A>     * Add a class or interface. This method instantiates a class file
<FONT ID="LN">925 </FONT><A NAME="925"></A>     * representation in memory, so must be called prior to methods that add
<FONT ID="LN">926 </FONT><A NAME="926"></A>     * information (fields, methods, instructions, etc.) to the class.
<FONT ID="LN">927 </FONT><A NAME="927"></A>     * 
<FONT ID="LN">928 </FONT><A NAME="928"></A>     * @param accessFlags
<FONT ID="LN">929 </FONT><A NAME="929"></A>     *            the access flags for the class or interface.
<FONT ID="LN">930 </FONT><A NAME="930"></A>     * @param thisClass
<FONT ID="LN">931 </FONT><A NAME="931"></A>     *            fully qualified name of the class or interface in internal
<FONT ID="LN">932 </FONT><A NAME="932"></A>     *            form.
<FONT ID="LN">933 </FONT><A NAME="933"></A>     * @param superClass
<FONT ID="LN">934 </FONT><A NAME="934"></A>     *            fully qualified name of the parent class in internal form.
<FONT ID="LN">935 </FONT><A NAME="935"></A>     * @param superInterfaces
<FONT ID="LN">936 </FONT><A NAME="936"></A>     *            list of direct super interfaces of this class or interface as
<FONT ID="LN">937 </FONT><A NAME="937"></A>     *            fully qualified names in internal form.
<FONT ID="LN">938 </FONT><A NAME="938"></A>     * @param isSynthetic
<FONT ID="LN">939 </FONT><A NAME="939"></A>     *            whether the class or interface is synthetic.
<FONT ID="LN">940 </FONT><A NAME="940"></A>     */</FONT>
<FONT ID="LN">941 </FONT><A NAME="941"></A>
<FONT ID="LN">942 </FONT><A NAME="942"></A>    <FONT ID="Public">public</FONT> <FONT ID="Void">void</FONT> addClass(ArrayList&lt;String&gt; accessFlags, String thisClass,
<FONT ID="LN">943 </FONT><A NAME="943"></A>            String superClass, ArrayList&lt;String&gt; superInterfaces,
<FONT ID="LN">944 </FONT><A NAME="944"></A>            <FONT ID="Boolean">boolean</FONT> isSynthetic) {
<FONT ID="LN">945 </FONT><A NAME="945"></A>        clFile = <FONT ID="New">new</FONT> <A HREF="../jminusminus/CLFile.java.html">CLFile</A>();
<FONT ID="LN">946 </FONT><A NAME="946"></A>        constantPool = <FONT ID="New">new</FONT> <A HREF="../jminusminus/CLConstantPool.java.html">CLConstantPool</A>();
<FONT ID="LN">947 </FONT><A NAME="947"></A>        interfaces = <FONT ID="New">new</FONT> ArrayList&lt;Integer&gt;();
<FONT ID="LN">948 </FONT><A NAME="948"></A>        fields = <FONT ID="New">new</FONT> ArrayList&lt;CLFieldInfo&gt;();
<FONT ID="LN">949 </FONT><A NAME="949"></A>        methods = <FONT ID="New">new</FONT> ArrayList&lt;CLMethodInfo&gt;();
<FONT ID="LN">950 </FONT><A NAME="950"></A>        attributes = <FONT ID="New">new</FONT> ArrayList&lt;<A HREF="../jminusminus/CLAttributeInfo.java.html">CLAttributeInfo</A>&gt;();
<FONT ID="LN">951 </FONT><A NAME="951"></A>        innerClasses = <FONT ID="New">new</FONT> ArrayList&lt;CLInnerClassInfo&gt;();
<FONT ID="LN">952 </FONT><A NAME="952"></A>        errorHasOccurred = <FONT ID="False">false</FONT>;
<FONT ID="LN">953 </FONT><A NAME="953"></A>        clFile.magic = MAGIC;
<FONT ID="LN">954 </FONT><A NAME="954"></A>        clFile.majorVersion = MAJOR_VERSION;
<FONT ID="LN">955 </FONT><A NAME="955"></A>        clFile.minorVersion = MINOR_VERSION;
<FONT ID="LN">956 </FONT><A NAME="956"></A>        <FONT ID="If">if</FONT> (!validInternalForm(thisClass)) {
<FONT ID="LN">957 </FONT><A NAME="957"></A>            reportEmitterError(<FONT ID="StringLiteral">"'%s' is not in internal form"</FONT>, thisClass);
<FONT ID="LN">958 </FONT><A NAME="958"></A>        }
<FONT ID="LN">959 </FONT><A NAME="959"></A>        <FONT ID="If">if</FONT> (!validInternalForm(superClass)) {
<FONT ID="LN">960 </FONT><A NAME="960"></A>            reportEmitterError(<FONT ID="StringLiteral">"'%s' is not in internal form"</FONT>, superClass);
<FONT ID="LN">961 </FONT><A NAME="961"></A>        }
<FONT ID="LN">962 </FONT><A NAME="962"></A>        <FONT ID="If">if</FONT> (accessFlags != <FONT ID="Null">null</FONT>) {
<FONT ID="LN">963 </FONT><A NAME="963"></A>            <FONT ID="For">for</FONT> (<FONT ID="Int">int</FONT> i = <FONT ID="IntegerLiteral">0</FONT>; i &lt; accessFlags.size(); i++) {
<FONT ID="LN">964 </FONT><A NAME="964"></A>                clFile.accessFlags |= CLFile
<FONT ID="LN">965 </FONT><A NAME="965"></A>                        .accessFlagToInt(accessFlags.get(i));
<FONT ID="LN">966 </FONT><A NAME="966"></A>            }
<FONT ID="LN">967 </FONT><A NAME="967"></A>        }
<FONT ID="LN">968 </FONT><A NAME="968"></A>        name = thisClass;
<FONT ID="LN">969 </FONT><A NAME="969"></A>        clFile.thisClass = constantPool.constantClassInfo(thisClass);
<FONT ID="LN">970 </FONT><A NAME="970"></A>        clFile.superClass = constantPool.constantClassInfo(superClass);
<FONT ID="LN">971 </FONT><A NAME="971"></A>        <FONT ID="For">for</FONT> (<FONT ID="Int">int</FONT> i = <FONT ID="IntegerLiteral">0</FONT>; superInterfaces != <FONT ID="Null">null</FONT> &amp;&amp; i &lt; superInterfaces.size(); i++) {
<FONT ID="LN">972 </FONT><A NAME="972"></A>            <FONT ID="If">if</FONT> (!validInternalForm(superInterfaces.get(i))) {
<FONT ID="LN">973 </FONT><A NAME="973"></A>                reportEmitterError(<FONT ID="StringLiteral">"'%s' is not in internal form"</FONT>,
<FONT ID="LN">974 </FONT><A NAME="974"></A>                        superInterfaces.get(i));
<FONT ID="LN">975 </FONT><A NAME="975"></A>            }
<FONT ID="LN">976 </FONT><A NAME="976"></A>            interfaces.add(<FONT ID="New">new</FONT> Integer(constantPool
<FONT ID="LN">977 </FONT><A NAME="977"></A>                    .constantClassInfo(superInterfaces.get(i))));
<FONT ID="LN">978 </FONT><A NAME="978"></A>        }
<FONT ID="LN">979 </FONT><A NAME="979"></A>        <FONT ID="If">if</FONT> (isSynthetic) {
<FONT ID="LN">980 </FONT><A NAME="980"></A>            addClassAttribute(syntheticAttribute());
<FONT ID="LN">981 </FONT><A NAME="981"></A>        }
<FONT ID="LN">982 </FONT><A NAME="982"></A>    }
<FONT ID="LN">983 </FONT><A NAME="983"></A>
<FONT ID="LN">984 </FONT><A NAME="984"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">985 </FONT><A NAME="985"></A>     * Add an inner class. Note that this only registers the inner class with
<FONT ID="LN">986 </FONT><A NAME="986"></A>     * its parent and does not create the class.
<FONT ID="LN">987 </FONT><A NAME="987"></A>     * 
<FONT ID="LN">988 </FONT><A NAME="988"></A>     * @param accessFlags
<FONT ID="LN">989 </FONT><A NAME="989"></A>     *            access flags for the inner class.
<FONT ID="LN">990 </FONT><A NAME="990"></A>     * @param innerClass
<FONT ID="LN">991 </FONT><A NAME="991"></A>     *            fully qualified name of the inner class in internal form.
<FONT ID="LN">992 </FONT><A NAME="992"></A>     * @param outerClass
<FONT ID="LN">993 </FONT><A NAME="993"></A>     *            fully qualified name of the outer class in internal form.
<FONT ID="LN">994 </FONT><A NAME="994"></A>     * @param innerName
<FONT ID="LN">995 </FONT><A NAME="995"></A>     *            simple name of the inner class.
<FONT ID="LN">996 </FONT><A NAME="996"></A>     */</FONT>
<FONT ID="LN">997 </FONT><A NAME="997"></A>
<FONT ID="LN">998 </FONT><A NAME="998"></A>    <FONT ID="Public">public</FONT> <FONT ID="Void">void</FONT> addInnerClass(ArrayList&lt;String&gt; accessFlags, String innerClass,
<FONT ID="LN">999 </FONT><A NAME="999"></A>            String outerClass, String innerName) {
<FONT ID="LN">1000</FONT><A NAME="1000"></A>        <FONT ID="Int">int</FONT> flags = <FONT ID="IntegerLiteral">0</FONT>;
<FONT ID="LN">1001</FONT><A NAME="1001"></A>        <FONT ID="If">if</FONT> (accessFlags != <FONT ID="Null">null</FONT>) {
<FONT ID="LN">1002</FONT><A NAME="1002"></A>            <FONT ID="For">for</FONT> (<FONT ID="Int">int</FONT> j = <FONT ID="IntegerLiteral">0</FONT>; j &lt; accessFlags.size(); j++) {
<FONT ID="LN">1003</FONT><A NAME="1003"></A>                flags |= CLFile.accessFlagToInt(accessFlags.get(j));
<FONT ID="LN">1004</FONT><A NAME="1004"></A>            }
<FONT ID="LN">1005</FONT><A NAME="1005"></A>        }
<FONT ID="LN">1006</FONT><A NAME="1006"></A>        CLInnerClassInfo innerClassInfo = <FONT ID="New">new</FONT> CLInnerClassInfo(constantPool
<FONT ID="LN">1007</FONT><A NAME="1007"></A>                .constantClassInfo(innerClass), constantPool
<FONT ID="LN">1008</FONT><A NAME="1008"></A>                .constantClassInfo(outerClass), constantPool
<FONT ID="LN">1009</FONT><A NAME="1009"></A>                .constantUtf8Info(innerName), flags);
<FONT ID="LN">1010</FONT><A NAME="1010"></A>        innerClasses.add(innerClassInfo);
<FONT ID="LN">1011</FONT><A NAME="1011"></A>    }
<FONT ID="LN">1012</FONT><A NAME="1012"></A>
<FONT ID="LN">1013</FONT><A NAME="1013"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1014</FONT><A NAME="1014"></A>     * Add a field without initialization.
<FONT ID="LN">1015</FONT><A NAME="1015"></A>     * 
<FONT ID="LN">1016</FONT><A NAME="1016"></A>     * @param accessFlags
<FONT ID="LN">1017</FONT><A NAME="1017"></A>     *            access flags for the field.
<FONT ID="LN">1018</FONT><A NAME="1018"></A>     * @param name
<FONT ID="LN">1019</FONT><A NAME="1019"></A>     *            name of the field.
<FONT ID="LN">1020</FONT><A NAME="1020"></A>     * @param type
<FONT ID="LN">1021</FONT><A NAME="1021"></A>     *            type descriptor of the field.
<FONT ID="LN">1022</FONT><A NAME="1022"></A>     * @param isSynthetic
<FONT ID="LN">1023</FONT><A NAME="1023"></A>     *            is this a synthetic field?
<FONT ID="LN">1024</FONT><A NAME="1024"></A>     */</FONT>
<FONT ID="LN">1025</FONT><A NAME="1025"></A>
<FONT ID="LN">1026</FONT><A NAME="1026"></A>    <FONT ID="Public">public</FONT> <FONT ID="Void">void</FONT> addField(ArrayList&lt;String&gt; accessFlags, String name,
<FONT ID="LN">1027</FONT><A NAME="1027"></A>            String type, <FONT ID="Boolean">boolean</FONT> isSynthetic) {
<FONT ID="LN">1028</FONT><A NAME="1028"></A>        addFieldInfo(accessFlags, name, type, isSynthetic, -<FONT ID="IntegerLiteral">1</FONT>);
<FONT ID="LN">1029</FONT><A NAME="1029"></A>    }
<FONT ID="LN">1030</FONT><A NAME="1030"></A>
<FONT ID="LN">1031</FONT><A NAME="1031"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1032</FONT><A NAME="1032"></A>     * Add an int, short, char, byte, or boolean field with initialization. If
<FONT ID="LN">1033</FONT><A NAME="1033"></A>     * the field is final, the initialization is added to the constant pool. The
<FONT ID="LN">1034</FONT><A NAME="1034"></A>     * initializations are all stored as ints, where boolean true and false are
<FONT ID="LN">1035</FONT><A NAME="1035"></A>     * 1 and 0 respectively, and short, char, and byte must be cast to int.
<FONT ID="LN">1036</FONT><A NAME="1036"></A>     * 
<FONT ID="LN">1037</FONT><A NAME="1037"></A>     * @param accessFlags
<FONT ID="LN">1038</FONT><A NAME="1038"></A>     *            access flags for the field.
<FONT ID="LN">1039</FONT><A NAME="1039"></A>     * @param name
<FONT ID="LN">1040</FONT><A NAME="1040"></A>     *            name of the field.
<FONT ID="LN">1041</FONT><A NAME="1041"></A>     * @param type
<FONT ID="LN">1042</FONT><A NAME="1042"></A>     *            type descriptor of the field.
<FONT ID="LN">1043</FONT><A NAME="1043"></A>     * @param isSynthetic
<FONT ID="LN">1044</FONT><A NAME="1044"></A>     *            is this a synthetic field?
<FONT ID="LN">1045</FONT><A NAME="1045"></A>     * @param i
<FONT ID="LN">1046</FONT><A NAME="1046"></A>     *            int value.
<FONT ID="LN">1047</FONT><A NAME="1047"></A>     */</FONT>
<FONT ID="LN">1048</FONT><A NAME="1048"></A>
<FONT ID="LN">1049</FONT><A NAME="1049"></A>    <FONT ID="Public">public</FONT> <FONT ID="Void">void</FONT> addField(ArrayList&lt;String&gt; accessFlags, String name,
<FONT ID="LN">1050</FONT><A NAME="1050"></A>            String type, <FONT ID="Boolean">boolean</FONT> isSynthetic, <FONT ID="Int">int</FONT> i) {
<FONT ID="LN">1051</FONT><A NAME="1051"></A>        addFieldInfo(accessFlags, name, type, isSynthetic, constantPool
<FONT ID="LN">1052</FONT><A NAME="1052"></A>                .constantIntegerInfo(i));
<FONT ID="LN">1053</FONT><A NAME="1053"></A>    }
<FONT ID="LN">1054</FONT><A NAME="1054"></A>
<FONT ID="LN">1055</FONT><A NAME="1055"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1056</FONT><A NAME="1056"></A>     * Add a float field with initialization. If the field is final, the
<FONT ID="LN">1057</FONT><A NAME="1057"></A>     * initialization is added to the constant pool.
<FONT ID="LN">1058</FONT><A NAME="1058"></A>     * 
<FONT ID="LN">1059</FONT><A NAME="1059"></A>     * @param accessFlags
<FONT ID="LN">1060</FONT><A NAME="1060"></A>     *            access flags for the field.
<FONT ID="LN">1061</FONT><A NAME="1061"></A>     * @param name
<FONT ID="LN">1062</FONT><A NAME="1062"></A>     *            name of the field.
<FONT ID="LN">1063</FONT><A NAME="1063"></A>     * @param isSynthetic
<FONT ID="LN">1064</FONT><A NAME="1064"></A>     *            is this a synthetic field?
<FONT ID="LN">1065</FONT><A NAME="1065"></A>     * @param f
<FONT ID="LN">1066</FONT><A NAME="1066"></A>     *            float value.
<FONT ID="LN">1067</FONT><A NAME="1067"></A>     */</FONT>
<FONT ID="LN">1068</FONT><A NAME="1068"></A>
<FONT ID="LN">1069</FONT><A NAME="1069"></A>    <FONT ID="Public">public</FONT> <FONT ID="Void">void</FONT> addField(ArrayList&lt;String&gt; accessFlags, String name,
<FONT ID="LN">1070</FONT><A NAME="1070"></A>            <FONT ID="Boolean">boolean</FONT> isSynthetic, <FONT ID="Float">float</FONT> f) {
<FONT ID="LN">1071</FONT><A NAME="1071"></A>        addFieldInfo(accessFlags, name, <FONT ID="StringLiteral">"F"</FONT>, isSynthetic, constantPool
<FONT ID="LN">1072</FONT><A NAME="1072"></A>                .constantFloatInfo(f));
<FONT ID="LN">1073</FONT><A NAME="1073"></A>    }
<FONT ID="LN">1074</FONT><A NAME="1074"></A>
<FONT ID="LN">1075</FONT><A NAME="1075"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1076</FONT><A NAME="1076"></A>     * Add a long field with initialization. If the field is final, the
<FONT ID="LN">1077</FONT><A NAME="1077"></A>     * initialization is added to the constant pool.
<FONT ID="LN">1078</FONT><A NAME="1078"></A>     * 
<FONT ID="LN">1079</FONT><A NAME="1079"></A>     * @param accessFlags
<FONT ID="LN">1080</FONT><A NAME="1080"></A>     *            access flags for the field.
<FONT ID="LN">1081</FONT><A NAME="1081"></A>     * @param name
<FONT ID="LN">1082</FONT><A NAME="1082"></A>     *            name of the field.
<FONT ID="LN">1083</FONT><A NAME="1083"></A>     * @param isSynthetic
<FONT ID="LN">1084</FONT><A NAME="1084"></A>     *            is this a synthetic field?
<FONT ID="LN">1085</FONT><A NAME="1085"></A>     * @param l
<FONT ID="LN">1086</FONT><A NAME="1086"></A>     *            long value.
<FONT ID="LN">1087</FONT><A NAME="1087"></A>     */</FONT>
<FONT ID="LN">1088</FONT><A NAME="1088"></A>
<FONT ID="LN">1089</FONT><A NAME="1089"></A>    <FONT ID="Public">public</FONT> <FONT ID="Void">void</FONT> addField(ArrayList&lt;String&gt; accessFlags, String name,
<FONT ID="LN">1090</FONT><A NAME="1090"></A>            <FONT ID="Boolean">boolean</FONT> isSynthetic, <FONT ID="Long">long</FONT> l) {
<FONT ID="LN">1091</FONT><A NAME="1091"></A>        addFieldInfo(accessFlags, name, <FONT ID="StringLiteral">"J"</FONT>, isSynthetic, constantPool
<FONT ID="LN">1092</FONT><A NAME="1092"></A>                .constantLongInfo(l));
<FONT ID="LN">1093</FONT><A NAME="1093"></A>    }
<FONT ID="LN">1094</FONT><A NAME="1094"></A>
<FONT ID="LN">1095</FONT><A NAME="1095"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1096</FONT><A NAME="1096"></A>     * Add a double field with initialization. If the field is final, the
<FONT ID="LN">1097</FONT><A NAME="1097"></A>     * initialization is added to the constant pool.
<FONT ID="LN">1098</FONT><A NAME="1098"></A>     * 
<FONT ID="LN">1099</FONT><A NAME="1099"></A>     * @param accessFlags
<FONT ID="LN">1100</FONT><A NAME="1100"></A>     *            access flags for the field.
<FONT ID="LN">1101</FONT><A NAME="1101"></A>     * @param name
<FONT ID="LN">1102</FONT><A NAME="1102"></A>     *            name of the field.
<FONT ID="LN">1103</FONT><A NAME="1103"></A>     * @param isSynthetic
<FONT ID="LN">1104</FONT><A NAME="1104"></A>     *            is this a synthetic field?
<FONT ID="LN">1105</FONT><A NAME="1105"></A>     * @param d
<FONT ID="LN">1106</FONT><A NAME="1106"></A>     *            double value.
<FONT ID="LN">1107</FONT><A NAME="1107"></A>     */</FONT>
<FONT ID="LN">1108</FONT><A NAME="1108"></A>
<FONT ID="LN">1109</FONT><A NAME="1109"></A>    <FONT ID="Public">public</FONT> <FONT ID="Void">void</FONT> addField(ArrayList&lt;String&gt; accessFlags, String name,
<FONT ID="LN">1110</FONT><A NAME="1110"></A>            <FONT ID="Boolean">boolean</FONT> isSynthetic, <FONT ID="Double">double</FONT> d) {
<FONT ID="LN">1111</FONT><A NAME="1111"></A>        addFieldInfo(accessFlags, name, <FONT ID="StringLiteral">"D"</FONT>, isSynthetic, constantPool
<FONT ID="LN">1112</FONT><A NAME="1112"></A>                .constantDoubleInfo(d));
<FONT ID="LN">1113</FONT><A NAME="1113"></A>    }
<FONT ID="LN">1114</FONT><A NAME="1114"></A>
<FONT ID="LN">1115</FONT><A NAME="1115"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1116</FONT><A NAME="1116"></A>     * Add a String type field with initialization. If the field is final, the
<FONT ID="LN">1117</FONT><A NAME="1117"></A>     * initialization is added to the constant pool.
<FONT ID="LN">1118</FONT><A NAME="1118"></A>     * 
<FONT ID="LN">1119</FONT><A NAME="1119"></A>     * @param accessFlags
<FONT ID="LN">1120</FONT><A NAME="1120"></A>     *            access flags for the field.
<FONT ID="LN">1121</FONT><A NAME="1121"></A>     * @param name
<FONT ID="LN">1122</FONT><A NAME="1122"></A>     *            name of the field.
<FONT ID="LN">1123</FONT><A NAME="1123"></A>     * @param isSynthetic
<FONT ID="LN">1124</FONT><A NAME="1124"></A>     *            is this a synthetic field?
<FONT ID="LN">1125</FONT><A NAME="1125"></A>     * @param s
<FONT ID="LN">1126</FONT><A NAME="1126"></A>     *            String value.
<FONT ID="LN">1127</FONT><A NAME="1127"></A>     */</FONT>
<FONT ID="LN">1128</FONT><A NAME="1128"></A>
<FONT ID="LN">1129</FONT><A NAME="1129"></A>    <FONT ID="Public">public</FONT> <FONT ID="Void">void</FONT> addField(ArrayList&lt;String&gt; accessFlags, String name,
<FONT ID="LN">1130</FONT><A NAME="1130"></A>            <FONT ID="Boolean">boolean</FONT> isSynthetic, String s) {
<FONT ID="LN">1131</FONT><A NAME="1131"></A>        addFieldInfo(accessFlags, name, <FONT ID="StringLiteral">"Ljava/lang/String;"</FONT>, isSynthetic,
<FONT ID="LN">1132</FONT><A NAME="1132"></A>                constantPool.constantStringInfo(s));
<FONT ID="LN">1133</FONT><A NAME="1133"></A>    }
<FONT ID="LN">1134</FONT><A NAME="1134"></A>
<FONT ID="LN">1135</FONT><A NAME="1135"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1136</FONT><A NAME="1136"></A>     * Add a method. Instructions can subsequently be added to this method using
<FONT ID="LN">1137</FONT><A NAME="1137"></A>     * the appropriate methods for adding instructions.
<FONT ID="LN">1138</FONT><A NAME="1138"></A>     * 
<FONT ID="LN">1139</FONT><A NAME="1139"></A>     * @param accessFlags
<FONT ID="LN">1140</FONT><A NAME="1140"></A>     *            access flags for the method.
<FONT ID="LN">1141</FONT><A NAME="1141"></A>     * @param name
<FONT ID="LN">1142</FONT><A NAME="1142"></A>     *            name of the method.
<FONT ID="LN">1143</FONT><A NAME="1143"></A>     * @param descriptor
<FONT ID="LN">1144</FONT><A NAME="1144"></A>     *            descriptor specifying the return type and the types of the
<FONT ID="LN">1145</FONT><A NAME="1145"></A>     *            formal parameters of the method.
<FONT ID="LN">1146</FONT><A NAME="1146"></A>     * @param exceptions
<FONT ID="LN">1147</FONT><A NAME="1147"></A>     *            exceptions thrown by the method, each being a name in fully
<FONT ID="LN">1148</FONT><A NAME="1148"></A>     *            qualified internal form.
<FONT ID="LN">1149</FONT><A NAME="1149"></A>     * @param isSynthetic
<FONT ID="LN">1150</FONT><A NAME="1150"></A>     *            whether this is a synthetic method?
<FONT ID="LN">1151</FONT><A NAME="1151"></A>     */</FONT>
<FONT ID="LN">1152</FONT><A NAME="1152"></A>
<FONT ID="LN">1153</FONT><A NAME="1153"></A>    <FONT ID="Public">public</FONT> <FONT ID="Void">void</FONT> addMethod(ArrayList&lt;String&gt; accessFlags, String name,
<FONT ID="LN">1154</FONT><A NAME="1154"></A>            String descriptor, ArrayList&lt;String&gt; exceptions, <FONT ID="Boolean">boolean</FONT> isSynthetic) {
<FONT ID="LN">1155</FONT><A NAME="1155"></A>        <FONT ID="If">if</FONT> (!validMethodDescriptor(descriptor)) {
<FONT ID="LN">1156</FONT><A NAME="1156"></A>            reportEmitterError(
<FONT ID="LN">1157</FONT><A NAME="1157"></A>                    <FONT ID="StringLiteral">"'%s' is not a valid type descriptor for method"</FONT>,
<FONT ID="LN">1158</FONT><A NAME="1158"></A>                    descriptor);
<FONT ID="LN">1159</FONT><A NAME="1159"></A>        }
<FONT ID="LN">1160</FONT><A NAME="1160"></A>        endOpenMethodIfAny(); <FONT ID="SingleLineComment">// close any previous method
<FONT ID="LN">1161</FONT><A NAME="1161"></A></FONT>        isMethodOpen = <FONT ID="True">true</FONT>;
<FONT ID="LN">1162</FONT><A NAME="1162"></A>        initializeMethodVariables();
<FONT ID="LN">1163</FONT><A NAME="1163"></A>        eCurrentMethod = name + descriptor;
<FONT ID="LN">1164</FONT><A NAME="1164"></A>        <FONT ID="If">if</FONT> (accessFlags != <FONT ID="Null">null</FONT>) {
<FONT ID="LN">1165</FONT><A NAME="1165"></A>            <FONT ID="For">for</FONT> (<FONT ID="Int">int</FONT> i = <FONT ID="IntegerLiteral">0</FONT>; i &lt; accessFlags.size(); i++) {
<FONT ID="LN">1166</FONT><A NAME="1166"></A>                mAccessFlags |= CLFile.accessFlagToInt(accessFlags.get(i));
<FONT ID="LN">1167</FONT><A NAME="1167"></A>            }
<FONT ID="LN">1168</FONT><A NAME="1168"></A>        }
<FONT ID="LN">1169</FONT><A NAME="1169"></A>        mArgumentCount = argumentCount(descriptor)
<FONT ID="LN">1170</FONT><A NAME="1170"></A>                + (accessFlags.contains(<FONT ID="StringLiteral">"static"</FONT>) ? <FONT ID="IntegerLiteral">0</FONT> : <FONT ID="IntegerLiteral">1</FONT>);
<FONT ID="LN">1171</FONT><A NAME="1171"></A>        mNameIndex = constantPool.constantUtf8Info(name);
<FONT ID="LN">1172</FONT><A NAME="1172"></A>        mDescriptorIndex = constantPool.constantUtf8Info(descriptor);
<FONT ID="LN">1173</FONT><A NAME="1173"></A>        <FONT ID="If">if</FONT> (exceptions != <FONT ID="Null">null</FONT> &amp;&amp; exceptions.size() &gt; <FONT ID="IntegerLiteral">0</FONT>) {
<FONT ID="LN">1174</FONT><A NAME="1174"></A>            addMethodAttribute(exceptionsAttribute(exceptions));
<FONT ID="LN">1175</FONT><A NAME="1175"></A>        }
<FONT ID="LN">1176</FONT><A NAME="1176"></A>        <FONT ID="If">if</FONT> (isSynthetic) {
<FONT ID="LN">1177</FONT><A NAME="1177"></A>            addMethodAttribute(syntheticAttribute());
<FONT ID="LN">1178</FONT><A NAME="1178"></A>        }
<FONT ID="LN">1179</FONT><A NAME="1179"></A>    }
<FONT ID="LN">1180</FONT><A NAME="1180"></A>
<FONT ID="LN">1181</FONT><A NAME="1181"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1182</FONT><A NAME="1182"></A>     * Add an exception handler.
<FONT ID="LN">1183</FONT><A NAME="1183"></A>     * 
<FONT ID="LN">1184</FONT><A NAME="1184"></A>     * @param startLabel
<FONT ID="LN">1185</FONT><A NAME="1185"></A>     *            the exception handler is active from the instruction following
<FONT ID="LN">1186</FONT><A NAME="1186"></A>     *            this label in the code section of the current method being
<FONT ID="LN">1187</FONT><A NAME="1187"></A>     *            added ...
<FONT ID="LN">1188</FONT><A NAME="1188"></A>     * @param endLabel
<FONT ID="LN">1189</FONT><A NAME="1189"></A>     *            to the instruction following this label. Formally, the handler
<FONT ID="LN">1190</FONT><A NAME="1190"></A>     *            is active while the program counter is within the interval
<FONT ID="LN">1191</FONT><A NAME="1191"></A>     *            [startLabel, endLabel).
<FONT ID="LN">1192</FONT><A NAME="1192"></A>     * @param handlerLabel
<FONT ID="LN">1193</FONT><A NAME="1193"></A>     *            the handler begins with instruction following this label.
<FONT ID="LN">1194</FONT><A NAME="1194"></A>     * @param catchType
<FONT ID="LN">1195</FONT><A NAME="1195"></A>     *            the exception type that this exception handler is designated
<FONT ID="LN">1196</FONT><A NAME="1196"></A>     *            to catch, as a fully qualified name in internal form. If null,
<FONT ID="LN">1197</FONT><A NAME="1197"></A>     *            this exception handler is called for all exceptions; this is
<FONT ID="LN">1198</FONT><A NAME="1198"></A>     *            used to immplement "finally".
<FONT ID="LN">1199</FONT><A NAME="1199"></A>     */</FONT>
<FONT ID="LN">1200</FONT><A NAME="1200"></A>
<FONT ID="LN">1201</FONT><A NAME="1201"></A>    <FONT ID="Public">public</FONT> <FONT ID="Void">void</FONT> addExceptionHandler(String startLabel, String endLabel,
<FONT ID="LN">1202</FONT><A NAME="1202"></A>            String handlerLabel, String catchType) {
<FONT ID="LN">1203</FONT><A NAME="1203"></A>        <FONT ID="If">if</FONT> (catchType != <FONT ID="Null">null</FONT> &amp;&amp; !validInternalForm(catchType)) {
<FONT ID="LN">1204</FONT><A NAME="1204"></A>            reportEmitterError(<FONT ID="StringLiteral">"'%s' is not in internal form"</FONT>, catchType);
<FONT ID="LN">1205</FONT><A NAME="1205"></A>        }
<FONT ID="LN">1206</FONT><A NAME="1206"></A>        CLException e = <FONT ID="New">new</FONT> CLException(startLabel, endLabel, handlerLabel,
<FONT ID="LN">1207</FONT><A NAME="1207"></A>                catchType);
<FONT ID="LN">1208</FONT><A NAME="1208"></A>        mExceptionHandlers.add(e);
<FONT ID="LN">1209</FONT><A NAME="1209"></A>    }
<FONT ID="LN">1210</FONT><A NAME="1210"></A>
<FONT ID="LN">1211</FONT><A NAME="1211"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1212</FONT><A NAME="1212"></A>     * Add a no argument instruction. Following instructions can be added using
<FONT ID="LN">1213</FONT><A NAME="1213"></A>     * this method:
<FONT ID="LN">1214</FONT><A NAME="1214"></A>     * 
<FONT ID="LN">1215</FONT><A NAME="1215"></A>     * &lt;p/&gt;
<FONT ID="LN">1216</FONT><A NAME="1216"></A>     * Arithmetic Instructions:
<FONT ID="LN">1217</FONT><A NAME="1217"></A>     * 
<FONT ID="LN">1218</FONT><A NAME="1218"></A>     * &lt;pre&gt;
<FONT ID="LN">1219</FONT><A NAME="1219"></A>     *   IADD, LADD, FADD, DADD, ISUB, LSUB, FSUB, DSUB, IMUL, 
<FONT ID="LN">1220</FONT><A NAME="1220"></A>     *   LMUL, FMUL, DMUL, IDIV, LDIV, FDIV, DDIV, IREM, LREM, FREM, 
<FONT ID="LN">1221</FONT><A NAME="1221"></A>     *   DREM, INEG, LNEG, FNEG, DNEG
<FONT ID="LN">1222</FONT><A NAME="1222"></A>     * &lt;/pre&gt;
<FONT ID="LN">1223</FONT><A NAME="1223"></A>     * 
<FONT ID="LN">1224</FONT><A NAME="1224"></A>     * &lt;p/&gt;
<FONT ID="LN">1225</FONT><A NAME="1225"></A>     * Array Instructions:
<FONT ID="LN">1226</FONT><A NAME="1226"></A>     * 
<FONT ID="LN">1227</FONT><A NAME="1227"></A>     * &lt;pre&gt;
<FONT ID="LN">1228</FONT><A NAME="1228"></A>     *   IALOAD, LALOAD, FALOAD, DALOAD, AALOAD, BALOAD, CALOAD, 
<FONT ID="LN">1229</FONT><A NAME="1229"></A>     *   SALOAD, IASTORE, LASTORE, FASTORE, DASTORE, AASTORE, 
<FONT ID="LN">1230</FONT><A NAME="1230"></A>     *   BASTORE, CASTORE, SASTORE, ARRAYLENGTH
<FONT ID="LN">1231</FONT><A NAME="1231"></A>     * &lt;/pre&gt;
<FONT ID="LN">1232</FONT><A NAME="1232"></A>     * 
<FONT ID="LN">1233</FONT><A NAME="1233"></A>     * &lt;p/&gt;
<FONT ID="LN">1234</FONT><A NAME="1234"></A>     * Bit Instructions:
<FONT ID="LN">1235</FONT><A NAME="1235"></A>     * 
<FONT ID="LN">1236</FONT><A NAME="1236"></A>     * &lt;pre&gt;
<FONT ID="LN">1237</FONT><A NAME="1237"></A>     *   ISHL, ISHR, IUSHR, LSHL, LSHR, LUSHR, IOR, LOR, IAND, LAND, 
<FONT ID="LN">1238</FONT><A NAME="1238"></A>     *   IXOR, LXOR
<FONT ID="LN">1239</FONT><A NAME="1239"></A>     * &lt;/pre&gt;
<FONT ID="LN">1240</FONT><A NAME="1240"></A>     * 
<FONT ID="LN">1241</FONT><A NAME="1241"></A>     * &lt;p/&gt;
<FONT ID="LN">1242</FONT><A NAME="1242"></A>     * Comparison Instructions:
<FONT ID="LN">1243</FONT><A NAME="1243"></A>     * 
<FONT ID="LN">1244</FONT><A NAME="1244"></A>     * &lt;pre&gt;
<FONT ID="LN">1245</FONT><A NAME="1245"></A>     *   DCMPG, DCMPL, FCMPG, FCMPL, LCMP
<FONT ID="LN">1246</FONT><A NAME="1246"></A>     * &lt;/pre&gt;
<FONT ID="LN">1247</FONT><A NAME="1247"></A>     * 
<FONT ID="LN">1248</FONT><A NAME="1248"></A>     * &lt;p/&gt;
<FONT ID="LN">1249</FONT><A NAME="1249"></A>     * Conversion Instructions:
<FONT ID="LN">1250</FONT><A NAME="1250"></A>     * 
<FONT ID="LN">1251</FONT><A NAME="1251"></A>     * &lt;pre&gt;
<FONT ID="LN">1252</FONT><A NAME="1252"></A>     *   I2B, I2C, I2S, I2L, I2F, I2D, L2F, L2D, L2I, F2D, F2I, 
<FONT ID="LN">1253</FONT><A NAME="1253"></A>     *   F2L, D2I, D2L, D2F
<FONT ID="LN">1254</FONT><A NAME="1254"></A>     * &lt;/pre&gt;
<FONT ID="LN">1255</FONT><A NAME="1255"></A>     * 
<FONT ID="LN">1256</FONT><A NAME="1256"></A>     * &lt;p/&gt;
<FONT ID="LN">1257</FONT><A NAME="1257"></A>     * Load Store Instructions:
<FONT ID="LN">1258</FONT><A NAME="1258"></A>     * 
<FONT ID="LN">1259</FONT><A NAME="1259"></A>     * &lt;pre&gt;
<FONT ID="LN">1260</FONT><A NAME="1260"></A>     *   ILOAD_0, ILOAD_1, ILOAD_2, ILOAD_3, LLOAD_0, LLOAD_1, 
<FONT ID="LN">1261</FONT><A NAME="1261"></A>     *   LLOAD_2, LLOAD_3, FLOAD_0, FLOAD_1, FLOAD_2, FLOAD_3, 
<FONT ID="LN">1262</FONT><A NAME="1262"></A>     *   DLOAD_0, DLOAD_1, DLOAD_2, DLOAD_3, ALOAD_0, ALOAD_1, 
<FONT ID="LN">1263</FONT><A NAME="1263"></A>     *   ALOAD_2, ALOAD_3, ISTORE_0, ISTORE_1, ISTORE_2, ISTORE_3, 
<FONT ID="LN">1264</FONT><A NAME="1264"></A>     *   LSTORE_0, LSTORE_1, LSTORE_2, LSTORE_3, FSTORE_0, FSTORE_1, 
<FONT ID="LN">1265</FONT><A NAME="1265"></A>     *   FSTORE_2, FSTORE_3, DSTORE_0, DSTORE_1, DSTORE_2, DSTORE_3, 
<FONT ID="LN">1266</FONT><A NAME="1266"></A>     *   ASTORE_0, ASTORE_1, ASTORE_2, ASTORE_3, ICONST_0, ICONST_1, 
<FONT ID="LN">1267</FONT><A NAME="1267"></A>     *   ICONST_2, ICONST_3, ICONST_4, ICONST_5, ICONST_M1, LCONST_0, 
<FONT ID="LN">1268</FONT><A NAME="1268"></A>     *   LCONST_1, FCONST_0, FCONST_1, FCONST_2, DCONST_0, DCONST_1, 
<FONT ID="LN">1269</FONT><A NAME="1269"></A>     *   ACONST_NULL, WIDE (added automatically where necesary)
<FONT ID="LN">1270</FONT><A NAME="1270"></A>     * &lt;/pre&gt;
<FONT ID="LN">1271</FONT><A NAME="1271"></A>     * 
<FONT ID="LN">1272</FONT><A NAME="1272"></A>     * &lt;p/&gt;
<FONT ID="LN">1273</FONT><A NAME="1273"></A>     * Method Instructions:
<FONT ID="LN">1274</FONT><A NAME="1274"></A>     * 
<FONT ID="LN">1275</FONT><A NAME="1275"></A>     * &lt;pre&gt;
<FONT ID="LN">1276</FONT><A NAME="1276"></A>     *   IRETURN, LRETURN, FRETURN, DRETURN, ARETURN, RETURN
<FONT ID="LN">1277</FONT><A NAME="1277"></A>     * &lt;/pre&gt;
<FONT ID="LN">1278</FONT><A NAME="1278"></A>     * 
<FONT ID="LN">1279</FONT><A NAME="1279"></A>     * &lt;p/&gt;
<FONT ID="LN">1280</FONT><A NAME="1280"></A>     * Stack Instructions:
<FONT ID="LN">1281</FONT><A NAME="1281"></A>     * 
<FONT ID="LN">1282</FONT><A NAME="1282"></A>     * &lt;pre&gt;
<FONT ID="LN">1283</FONT><A NAME="1283"></A>     *   POP, POP2, DUP, DUP_X1, DUP_X2, DUP2, DUP2_X1, DUP2_X2, SWAP
<FONT ID="LN">1284</FONT><A NAME="1284"></A>     * &lt;/pre&gt;
<FONT ID="LN">1285</FONT><A NAME="1285"></A>     * 
<FONT ID="LN">1286</FONT><A NAME="1286"></A>     * &lt;p/&gt;
<FONT ID="LN">1287</FONT><A NAME="1287"></A>     * Miscellaneous Instructions:
<FONT ID="LN">1288</FONT><A NAME="1288"></A>     * 
<FONT ID="LN">1289</FONT><A NAME="1289"></A>     * &lt;pre&gt;
<FONT ID="LN">1290</FONT><A NAME="1290"></A>     *   NOP, ATHROW, MONITORENTER, MONITOREXIT
<FONT ID="LN">1291</FONT><A NAME="1291"></A>     * &lt;/pre&gt;
<FONT ID="LN">1292</FONT><A NAME="1292"></A>     * 
<FONT ID="LN">1293</FONT><A NAME="1293"></A>     * The opcodes for instructions are defined in CLConstants class.
<FONT ID="LN">1294</FONT><A NAME="1294"></A>     * 
<FONT ID="LN">1295</FONT><A NAME="1295"></A>     * @param opcode
<FONT ID="LN">1296</FONT><A NAME="1296"></A>     *            opcode of the instruction.
<FONT ID="LN">1297</FONT><A NAME="1297"></A>     */</FONT>
<FONT ID="LN">1298</FONT><A NAME="1298"></A>
<FONT ID="LN">1299</FONT><A NAME="1299"></A>    <FONT ID="Public">public</FONT> <FONT ID="Void">void</FONT> addNoArgInstruction(<FONT ID="Int">int</FONT> opcode) {
<FONT ID="LN">1300</FONT><A NAME="1300"></A>        <A HREF="../jminusminus/CLInstruction.java.html">CLInstruction</A> instr = <FONT ID="Null">null</FONT>;
<FONT ID="LN">1301</FONT><A NAME="1301"></A>        <FONT ID="Switch">switch</FONT> (CLInstruction.instructionInfo[opcode].category) {
<FONT ID="LN">1302</FONT><A NAME="1302"></A>        <FONT ID="Case">case</FONT> ARITHMETIC1:
<FONT ID="LN">1303</FONT><A NAME="1303"></A>            instr = <FONT ID="New">new</FONT> CLArithmeticInstruction(opcode, mPC++);
<FONT ID="LN">1304</FONT><A NAME="1304"></A>            <FONT ID="Break">break</FONT>;
<FONT ID="LN">1305</FONT><A NAME="1305"></A>        <FONT ID="Case">case</FONT> ARRAY2:
<FONT ID="LN">1306</FONT><A NAME="1306"></A>            instr = <FONT ID="New">new</FONT> CLArrayInstruction(opcode, mPC++);
<FONT ID="LN">1307</FONT><A NAME="1307"></A>            <FONT ID="Break">break</FONT>;
<FONT ID="LN">1308</FONT><A NAME="1308"></A>        <FONT ID="Case">case</FONT> BIT:
<FONT ID="LN">1309</FONT><A NAME="1309"></A>            instr = <FONT ID="New">new</FONT> CLBitInstruction(opcode, mPC++);
<FONT ID="LN">1310</FONT><A NAME="1310"></A>            <FONT ID="Break">break</FONT>;
<FONT ID="LN">1311</FONT><A NAME="1311"></A>        <FONT ID="Case">case</FONT> COMPARISON:
<FONT ID="LN">1312</FONT><A NAME="1312"></A>            instr = <FONT ID="New">new</FONT> CLComparisonInstruction(opcode, mPC++);
<FONT ID="LN">1313</FONT><A NAME="1313"></A>            <FONT ID="Break">break</FONT>;
<FONT ID="LN">1314</FONT><A NAME="1314"></A>        <FONT ID="Case">case</FONT> CONVERSION:
<FONT ID="LN">1315</FONT><A NAME="1315"></A>            instr = <FONT ID="New">new</FONT> CLConversionInstruction(opcode, mPC++);
<FONT ID="LN">1316</FONT><A NAME="1316"></A>            <FONT ID="Break">break</FONT>;
<FONT ID="LN">1317</FONT><A NAME="1317"></A>        <FONT ID="Case">case</FONT> LOAD_STORE1:
<FONT ID="LN">1318</FONT><A NAME="1318"></A>            instr = <FONT ID="New">new</FONT> CLLoadStoreInstruction(opcode, mPC++);
<FONT ID="LN">1319</FONT><A NAME="1319"></A>            <FONT ID="Break">break</FONT>;
<FONT ID="LN">1320</FONT><A NAME="1320"></A>        <FONT ID="Case">case</FONT> METHOD2:
<FONT ID="LN">1321</FONT><A NAME="1321"></A>            instr = <FONT ID="New">new</FONT> CLMethodInstruction(opcode, mPC++);
<FONT ID="LN">1322</FONT><A NAME="1322"></A>            <FONT ID="Break">break</FONT>;
<FONT ID="LN">1323</FONT><A NAME="1323"></A>        <FONT ID="Case">case</FONT> MISC:
<FONT ID="LN">1324</FONT><A NAME="1324"></A>            instr = <FONT ID="New">new</FONT> CLMiscInstruction(opcode, mPC++);
<FONT ID="LN">1325</FONT><A NAME="1325"></A>            <FONT ID="Break">break</FONT>;
<FONT ID="LN">1326</FONT><A NAME="1326"></A>        <FONT ID="Case">case</FONT> STACK:
<FONT ID="LN">1327</FONT><A NAME="1327"></A>            instr = <FONT ID="New">new</FONT> CLStackInstruction(opcode, mPC++);
<FONT ID="LN">1328</FONT><A NAME="1328"></A>            <FONT ID="Break">break</FONT>;
<FONT ID="LN">1329</FONT><A NAME="1329"></A>        <FONT ID="Default">default</FONT>:
<FONT ID="LN">1330</FONT><A NAME="1330"></A>            reportOpcodeError(opcode);
<FONT ID="LN">1331</FONT><A NAME="1331"></A>        }
<FONT ID="LN">1332</FONT><A NAME="1332"></A>        <FONT ID="If">if</FONT> (instr != <FONT ID="Null">null</FONT>) {
<FONT ID="LN">1333</FONT><A NAME="1333"></A>            mPC += instr.operandCount();
<FONT ID="LN">1334</FONT><A NAME="1334"></A>            mCode.add(instr);
<FONT ID="LN">1335</FONT><A NAME="1335"></A>            mInstructionAfterLabel = <FONT ID="True">true</FONT>;
<FONT ID="LN">1336</FONT><A NAME="1336"></A>        }
<FONT ID="LN">1337</FONT><A NAME="1337"></A>    }
<FONT ID="LN">1338</FONT><A NAME="1338"></A>
<FONT ID="LN">1339</FONT><A NAME="1339"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1340</FONT><A NAME="1340"></A>     * Add a one argument instruction. Wideable instructions are widened if
<FONT ID="LN">1341</FONT><A NAME="1341"></A>     * necessary by adding a WIDE instruction before the instruction. Following
<FONT ID="LN">1342</FONT><A NAME="1342"></A>     * instructions can be added using this method:
<FONT ID="LN">1343</FONT><A NAME="1343"></A>     * 
<FONT ID="LN">1344</FONT><A NAME="1344"></A>     * &lt;p/&gt;
<FONT ID="LN">1345</FONT><A NAME="1345"></A>     * Load Store Instructions:
<FONT ID="LN">1346</FONT><A NAME="1346"></A>     * 
<FONT ID="LN">1347</FONT><A NAME="1347"></A>     * &lt;pre&gt;
<FONT ID="LN">1348</FONT><A NAME="1348"></A>     *   ILOAD, LLOAD, FLOAD, DLOAD, ALOAD, ISTORE, LSTORE, FSTORE, 
<FONT ID="LN">1349</FONT><A NAME="1349"></A>     *   DSTORE, ASTORE, BIPUSH, SIPUSH
<FONT ID="LN">1350</FONT><A NAME="1350"></A>     * &lt;/pre&gt;
<FONT ID="LN">1351</FONT><A NAME="1351"></A>     * 
<FONT ID="LN">1352</FONT><A NAME="1352"></A>     * &lt;p/&gt;
<FONT ID="LN">1353</FONT><A NAME="1353"></A>     * Flow Control Instructions:
<FONT ID="LN">1354</FONT><A NAME="1354"></A>     * 
<FONT ID="LN">1355</FONT><A NAME="1355"></A>     * &lt;pre&gt;
<FONT ID="LN">1356</FONT><A NAME="1356"></A>     * RET
<FONT ID="LN">1357</FONT><A NAME="1357"></A>     * &lt;/pre&gt;
<FONT ID="LN">1358</FONT><A NAME="1358"></A>     * 
<FONT ID="LN">1359</FONT><A NAME="1359"></A>     * The opcodes for instructions are defined in CLConstants class.
<FONT ID="LN">1360</FONT><A NAME="1360"></A>     * 
<FONT ID="LN">1361</FONT><A NAME="1361"></A>     * @param opcode
<FONT ID="LN">1362</FONT><A NAME="1362"></A>     *            opcode of the instruction.
<FONT ID="LN">1363</FONT><A NAME="1363"></A>     * @param arg
<FONT ID="LN">1364</FONT><A NAME="1364"></A>     *            the argument. For the instructions that deal with local
<FONT ID="LN">1365</FONT><A NAME="1365"></A>     *            variables, the argument is the local variable index; for
<FONT ID="LN">1366</FONT><A NAME="1366"></A>     *            BIPUSH and SIPUSH instructions, the argument is the constant
<FONT ID="LN">1367</FONT><A NAME="1367"></A>     *            byte or short value.
<FONT ID="LN">1368</FONT><A NAME="1368"></A>     */</FONT>
<FONT ID="LN">1369</FONT><A NAME="1369"></A>
<FONT ID="LN">1370</FONT><A NAME="1370"></A>    <FONT ID="Public">public</FONT> <FONT ID="Void">void</FONT> addOneArgInstruction(<FONT ID="Int">int</FONT> opcode, <FONT ID="Int">int</FONT> arg) {
<FONT ID="LN">1371</FONT><A NAME="1371"></A>        <A HREF="../jminusminus/CLInstruction.java.html">CLInstruction</A> instr = <FONT ID="Null">null</FONT>;
<FONT ID="LN">1372</FONT><A NAME="1372"></A>        <FONT ID="Boolean">boolean</FONT> isWidened = <FONT ID="False">false</FONT>;
<FONT ID="LN">1373</FONT><A NAME="1373"></A>        <FONT ID="Switch">switch</FONT> (CLInstruction.instructionInfo[opcode].category) {
<FONT ID="LN">1374</FONT><A NAME="1374"></A>        <FONT ID="Case">case</FONT> LOAD_STORE2:
<FONT ID="LN">1375</FONT><A NAME="1375"></A>            isWidened = arg &gt; <FONT ID="IntegerLiteral">255</FONT>;
<FONT ID="LN">1376</FONT><A NAME="1376"></A>            <FONT ID="If">if</FONT> (isWidened) {
<FONT ID="LN">1377</FONT><A NAME="1377"></A>                CLLoadStoreInstruction wideInstr = <FONT ID="New">new</FONT> CLLoadStoreInstruction(
<FONT ID="LN">1378</FONT><A NAME="1378"></A>                        WIDE, mPC++);
<FONT ID="LN">1379</FONT><A NAME="1379"></A>                mCode.add(wideInstr);
<FONT ID="LN">1380</FONT><A NAME="1380"></A>            }
<FONT ID="LN">1381</FONT><A NAME="1381"></A>            instr = <FONT ID="New">new</FONT> CLLoadStoreInstruction(opcode, mPC++, arg, isWidened);
<FONT ID="LN">1382</FONT><A NAME="1382"></A>            <FONT ID="Break">break</FONT>;
<FONT ID="LN">1383</FONT><A NAME="1383"></A>        <FONT ID="Case">case</FONT> LOAD_STORE3:
<FONT ID="LN">1384</FONT><A NAME="1384"></A>            instr = <FONT ID="New">new</FONT> CLLoadStoreInstruction(opcode, mPC++, arg);
<FONT ID="LN">1385</FONT><A NAME="1385"></A>            <FONT ID="Break">break</FONT>;
<FONT ID="LN">1386</FONT><A NAME="1386"></A>        <FONT ID="Case">case</FONT> FLOW_CONTROL2:
<FONT ID="LN">1387</FONT><A NAME="1387"></A>            isWidened = arg &gt; <FONT ID="IntegerLiteral">255</FONT>;
<FONT ID="LN">1388</FONT><A NAME="1388"></A>            <FONT ID="If">if</FONT> (isWidened) {
<FONT ID="LN">1389</FONT><A NAME="1389"></A>                CLLoadStoreInstruction wideInstr = <FONT ID="New">new</FONT> CLLoadStoreInstruction(
<FONT ID="LN">1390</FONT><A NAME="1390"></A>                        WIDE, mPC++);
<FONT ID="LN">1391</FONT><A NAME="1391"></A>                mCode.add(wideInstr);
<FONT ID="LN">1392</FONT><A NAME="1392"></A>            }
<FONT ID="LN">1393</FONT><A NAME="1393"></A>            instr = <FONT ID="New">new</FONT> CLFlowControlInstruction(mPC++, arg, isWidened);
<FONT ID="LN">1394</FONT><A NAME="1394"></A>            <FONT ID="Break">break</FONT>;
<FONT ID="LN">1395</FONT><A NAME="1395"></A>        <FONT ID="Default">default</FONT>:
<FONT ID="LN">1396</FONT><A NAME="1396"></A>            reportOpcodeError(opcode);
<FONT ID="LN">1397</FONT><A NAME="1397"></A>        }
<FONT ID="LN">1398</FONT><A NAME="1398"></A>        <FONT ID="If">if</FONT> (instr != <FONT ID="Null">null</FONT>) {
<FONT ID="LN">1399</FONT><A NAME="1399"></A>            mPC += instr.operandCount();
<FONT ID="LN">1400</FONT><A NAME="1400"></A>            mCode.add(instr);
<FONT ID="LN">1401</FONT><A NAME="1401"></A>            mInstructionAfterLabel = <FONT ID="True">true</FONT>;
<FONT ID="LN">1402</FONT><A NAME="1402"></A>        }
<FONT ID="LN">1403</FONT><A NAME="1403"></A>    }
<FONT ID="LN">1404</FONT><A NAME="1404"></A>
<FONT ID="LN">1405</FONT><A NAME="1405"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1406</FONT><A NAME="1406"></A>     * Add an IINC instruction to increment a variable by a constant. The
<FONT ID="LN">1407</FONT><A NAME="1407"></A>     * instruction is widened if necessary by adding a WIDE instruction before
<FONT ID="LN">1408</FONT><A NAME="1408"></A>     * the instruction.
<FONT ID="LN">1409</FONT><A NAME="1409"></A>     * 
<FONT ID="LN">1410</FONT><A NAME="1410"></A>     * @param index
<FONT ID="LN">1411</FONT><A NAME="1411"></A>     *            local variable index.
<FONT ID="LN">1412</FONT><A NAME="1412"></A>     * @param constVal
<FONT ID="LN">1413</FONT><A NAME="1413"></A>     *            increment value.
<FONT ID="LN">1414</FONT><A NAME="1414"></A>     */</FONT>
<FONT ID="LN">1415</FONT><A NAME="1415"></A>
<FONT ID="LN">1416</FONT><A NAME="1416"></A>    <FONT ID="Public">public</FONT> <FONT ID="Void">void</FONT> addIINCInstruction(<FONT ID="Int">int</FONT> index, <FONT ID="Int">int</FONT> constVal) {
<FONT ID="LN">1417</FONT><A NAME="1417"></A>        <FONT ID="Boolean">boolean</FONT> isWidened = index &gt; <FONT ID="IntegerLiteral">255</FONT> || constVal &lt; Byte.MIN_VALUE
<FONT ID="LN">1418</FONT><A NAME="1418"></A>                || constVal &gt; Byte.MAX_VALUE;
<FONT ID="LN">1419</FONT><A NAME="1419"></A>        <FONT ID="If">if</FONT> (isWidened) {
<FONT ID="LN">1420</FONT><A NAME="1420"></A>            CLLoadStoreInstruction wideInstr = <FONT ID="New">new</FONT> CLLoadStoreInstruction(WIDE,
<FONT ID="LN">1421</FONT><A NAME="1421"></A>                    mPC++);
<FONT ID="LN">1422</FONT><A NAME="1422"></A>            mCode.add(wideInstr);
<FONT ID="LN">1423</FONT><A NAME="1423"></A>        }
<FONT ID="LN">1424</FONT><A NAME="1424"></A>        CLArithmeticInstruction instr = <FONT ID="New">new</FONT> CLArithmeticInstruction(IINC,
<FONT ID="LN">1425</FONT><A NAME="1425"></A>                mPC++, index, constVal, isWidened);
<FONT ID="LN">1426</FONT><A NAME="1426"></A>        mPC += instr.operandCount();
<FONT ID="LN">1427</FONT><A NAME="1427"></A>        mCode.add(instr);
<FONT ID="LN">1428</FONT><A NAME="1428"></A>        mInstructionAfterLabel = <FONT ID="True">true</FONT>;
<FONT ID="LN">1429</FONT><A NAME="1429"></A>    }
<FONT ID="LN">1430</FONT><A NAME="1430"></A>
<FONT ID="LN">1431</FONT><A NAME="1431"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1432</FONT><A NAME="1432"></A>     * Add a member (field &amp; method) access instruction. Following instructions
<FONT ID="LN">1433</FONT><A NAME="1433"></A>     * can be added using this method:
<FONT ID="LN">1434</FONT><A NAME="1434"></A>     * 
<FONT ID="LN">1435</FONT><A NAME="1435"></A>     * &lt;p/&gt;
<FONT ID="LN">1436</FONT><A NAME="1436"></A>     * Field Instructions:
<FONT ID="LN">1437</FONT><A NAME="1437"></A>     * 
<FONT ID="LN">1438</FONT><A NAME="1438"></A>     * &lt;pre&gt;
<FONT ID="LN">1439</FONT><A NAME="1439"></A>     *   GETSTATIC, PUTSTATIC, GETFIELD, PUTFIELD
<FONT ID="LN">1440</FONT><A NAME="1440"></A>     * &lt;/pre&gt;
<FONT ID="LN">1441</FONT><A NAME="1441"></A>     * 
<FONT ID="LN">1442</FONT><A NAME="1442"></A>     * &lt;p/&gt;
<FONT ID="LN">1443</FONT><A NAME="1443"></A>     * Method Instructions:
<FONT ID="LN">1444</FONT><A NAME="1444"></A>     * 
<FONT ID="LN">1445</FONT><A NAME="1445"></A>     * &lt;pre&gt;
<FONT ID="LN">1446</FONT><A NAME="1446"></A>     *   INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC, INVOKEINTERFACE, 
<FONT ID="LN">1447</FONT><A NAME="1447"></A>     *   INVOKEDYNAMIC
<FONT ID="LN">1448</FONT><A NAME="1448"></A>     * &lt;/pre&gt;
<FONT ID="LN">1449</FONT><A NAME="1449"></A>     * 
<FONT ID="LN">1450</FONT><A NAME="1450"></A>     * The opcodes for instructions are defined in CLConstants class.
<FONT ID="LN">1451</FONT><A NAME="1451"></A>     * 
<FONT ID="LN">1452</FONT><A NAME="1452"></A>     * @param opcode
<FONT ID="LN">1453</FONT><A NAME="1453"></A>     *            opcode of the instruction.
<FONT ID="LN">1454</FONT><A NAME="1454"></A>     * @param target
<FONT ID="LN">1455</FONT><A NAME="1455"></A>     *            fully qualified name in internal form of the class to which
<FONT ID="LN">1456</FONT><A NAME="1456"></A>     *            the member belongs.
<FONT ID="LN">1457</FONT><A NAME="1457"></A>     * @param name
<FONT ID="LN">1458</FONT><A NAME="1458"></A>     *            name of the member.
<FONT ID="LN">1459</FONT><A NAME="1459"></A>     * @param type
<FONT ID="LN">1460</FONT><A NAME="1460"></A>     *            type descriptor of the member.
<FONT ID="LN">1461</FONT><A NAME="1461"></A>     */</FONT>
<FONT ID="LN">1462</FONT><A NAME="1462"></A>
<FONT ID="LN">1463</FONT><A NAME="1463"></A>    <FONT ID="Public">public</FONT> <FONT ID="Void">void</FONT> addMemberAccessInstruction(<FONT ID="Int">int</FONT> opcode, String target,
<FONT ID="LN">1464</FONT><A NAME="1464"></A>            String name, String type) {
<FONT ID="LN">1465</FONT><A NAME="1465"></A>        <FONT ID="If">if</FONT> (!validInternalForm(target)) {
<FONT ID="LN">1466</FONT><A NAME="1466"></A>            reportEmitterError(<FONT ID="StringLiteral">"%s: '%s' is not in internal form"</FONT>,
<FONT ID="LN">1467</FONT><A NAME="1467"></A>                    eCurrentMethod, target);
<FONT ID="LN">1468</FONT><A NAME="1468"></A>        }
<FONT ID="LN">1469</FONT><A NAME="1469"></A>        <A HREF="../jminusminus/CLInstruction.java.html">CLInstruction</A> instr = <FONT ID="Null">null</FONT>;
<FONT ID="LN">1470</FONT><A NAME="1470"></A>        <FONT ID="Int">int</FONT> index, stackUnits;
<FONT ID="LN">1471</FONT><A NAME="1471"></A>        <FONT ID="Switch">switch</FONT> (CLInstruction.instructionInfo[opcode].category) {
<FONT ID="LN">1472</FONT><A NAME="1472"></A>        <FONT ID="Case">case</FONT> FIELD:
<FONT ID="LN">1473</FONT><A NAME="1473"></A>            <FONT ID="If">if</FONT> (!validTypeDescriptor(type)) {
<FONT ID="LN">1474</FONT><A NAME="1474"></A>                reportEmitterError(
<FONT ID="LN">1475</FONT><A NAME="1475"></A>                        <FONT ID="StringLiteral">"%s: '%s' is not a valid type descriptor for field"</FONT>,
<FONT ID="LN">1476</FONT><A NAME="1476"></A>                        eCurrentMethod, type);
<FONT ID="LN">1477</FONT><A NAME="1477"></A>            }
<FONT ID="LN">1478</FONT><A NAME="1478"></A>            index = constantPool.constantFieldRefInfo(target, name, type);
<FONT ID="LN">1479</FONT><A NAME="1479"></A>            stackUnits = typeStackResidue(type);
<FONT ID="LN">1480</FONT><A NAME="1480"></A>            <FONT ID="If">if</FONT> ((opcode == GETFIELD) || (opcode == PUTFIELD)) {
<FONT ID="LN">1481</FONT><A NAME="1481"></A>                <FONT ID="SingleLineComment">// This is because target of this method is also
<FONT ID="LN">1482</FONT><A NAME="1482"></A></FONT>                <FONT ID="SingleLineComment">// consumed from the operand stack
<FONT ID="LN">1483</FONT><A NAME="1483"></A></FONT>                stackUnits--;
<FONT ID="LN">1484</FONT><A NAME="1484"></A>            }
<FONT ID="LN">1485</FONT><A NAME="1485"></A>            instr = <FONT ID="New">new</FONT> CLFieldInstruction(opcode, mPC++, index, stackUnits);
<FONT ID="LN">1486</FONT><A NAME="1486"></A>            <FONT ID="Break">break</FONT>;
<FONT ID="LN">1487</FONT><A NAME="1487"></A>        <FONT ID="Case">case</FONT> METHOD1:
<FONT ID="LN">1488</FONT><A NAME="1488"></A>            <FONT ID="If">if</FONT> (!validMethodDescriptor(type)) {
<FONT ID="LN">1489</FONT><A NAME="1489"></A>                reportEmitterError(
<FONT ID="LN">1490</FONT><A NAME="1490"></A>                        <FONT ID="StringLiteral">"%s: '%s' is not a valid type descriptor for "</FONT>
<FONT ID="LN">1491</FONT><A NAME="1491"></A>                                + <FONT ID="StringLiteral">"method"</FONT>, eCurrentMethod, type);
<FONT ID="LN">1492</FONT><A NAME="1492"></A>            }
<FONT ID="LN">1493</FONT><A NAME="1493"></A>            <FONT ID="If">if</FONT> (opcode == INVOKEINTERFACE) {
<FONT ID="LN">1494</FONT><A NAME="1494"></A>                index = constantPool.constantInterfaceMethodRefInfo(target,
<FONT ID="LN">1495</FONT><A NAME="1495"></A>                        name, type);
<FONT ID="LN">1496</FONT><A NAME="1496"></A>            } <FONT ID="Else">else</FONT> {
<FONT ID="LN">1497</FONT><A NAME="1497"></A>                index = constantPool.constantMethodRefInfo(target, name, type);
<FONT ID="LN">1498</FONT><A NAME="1498"></A>            }
<FONT ID="LN">1499</FONT><A NAME="1499"></A>            stackUnits = methodStackResidue(type);
<FONT ID="LN">1500</FONT><A NAME="1500"></A>            <FONT ID="If">if</FONT> (opcode != INVOKESTATIC) {
<FONT ID="LN">1501</FONT><A NAME="1501"></A>                <FONT ID="SingleLineComment">// This is because target of this method is also
<FONT ID="LN">1502</FONT><A NAME="1502"></A></FONT>                <FONT ID="SingleLineComment">// consumed from the operand stack
<FONT ID="LN">1503</FONT><A NAME="1503"></A></FONT>                stackUnits--;
<FONT ID="LN">1504</FONT><A NAME="1504"></A>            }
<FONT ID="LN">1505</FONT><A NAME="1505"></A>            instr = <FONT ID="New">new</FONT> CLMethodInstruction(opcode, mPC++, index, stackUnits);
<FONT ID="LN">1506</FONT><A NAME="1506"></A>
<FONT ID="LN">1507</FONT><A NAME="1507"></A>            <FONT ID="SingleLineComment">// INVOKEINTERFACE expects the number of arguments in
<FONT ID="LN">1508</FONT><A NAME="1508"></A></FONT>            <FONT ID="SingleLineComment">// the method to be specified explicitly.
<FONT ID="LN">1509</FONT><A NAME="1509"></A></FONT>            <FONT ID="If">if</FONT> (opcode == INVOKEINTERFACE) {
<FONT ID="LN">1510</FONT><A NAME="1510"></A>                <FONT ID="SingleLineComment">// We add 1 to account for "this"
<FONT ID="LN">1511</FONT><A NAME="1511"></A></FONT>                ((CLMethodInstruction) instr)
<FONT ID="LN">1512</FONT><A NAME="1512"></A>                        .setArgumentCount(argumentCount(type) + <FONT ID="IntegerLiteral">1</FONT>);
<FONT ID="LN">1513</FONT><A NAME="1513"></A>            }
<FONT ID="LN">1514</FONT><A NAME="1514"></A>            <FONT ID="Break">break</FONT>;
<FONT ID="LN">1515</FONT><A NAME="1515"></A>        <FONT ID="Default">default</FONT>:
<FONT ID="LN">1516</FONT><A NAME="1516"></A>            reportOpcodeError(opcode);
<FONT ID="LN">1517</FONT><A NAME="1517"></A>        }
<FONT ID="LN">1518</FONT><A NAME="1518"></A>        <FONT ID="If">if</FONT> (instr != <FONT ID="Null">null</FONT>) {
<FONT ID="LN">1519</FONT><A NAME="1519"></A>            mPC += instr.operandCount();
<FONT ID="LN">1520</FONT><A NAME="1520"></A>            mCode.add(instr);
<FONT ID="LN">1521</FONT><A NAME="1521"></A>        }
<FONT ID="LN">1522</FONT><A NAME="1522"></A>    }
<FONT ID="LN">1523</FONT><A NAME="1523"></A>
<FONT ID="LN">1524</FONT><A NAME="1524"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1525</FONT><A NAME="1525"></A>     * Add a reference (object) instruction. Following instructions can be added
<FONT ID="LN">1526</FONT><A NAME="1526"></A>     * using this method:
<FONT ID="LN">1527</FONT><A NAME="1527"></A>     * 
<FONT ID="LN">1528</FONT><A NAME="1528"></A>     * &lt;pre&gt;
<FONT ID="LN">1529</FONT><A NAME="1529"></A>     *   NEW, CHECKCAST, INSTANCEOF
<FONT ID="LN">1530</FONT><A NAME="1530"></A>     * &lt;/pre&gt;
<FONT ID="LN">1531</FONT><A NAME="1531"></A>     * 
<FONT ID="LN">1532</FONT><A NAME="1532"></A>     * The opcodes for instructions are defined in CLConstants class.
<FONT ID="LN">1533</FONT><A NAME="1533"></A>     * 
<FONT ID="LN">1534</FONT><A NAME="1534"></A>     * @param opcode
<FONT ID="LN">1535</FONT><A NAME="1535"></A>     *            opcode of the instruction.
<FONT ID="LN">1536</FONT><A NAME="1536"></A>     * @param type
<FONT ID="LN">1537</FONT><A NAME="1537"></A>     *            reference type in internal form.
<FONT ID="LN">1538</FONT><A NAME="1538"></A>     */</FONT>
<FONT ID="LN">1539</FONT><A NAME="1539"></A>
<FONT ID="LN">1540</FONT><A NAME="1540"></A>    <FONT ID="Public">public</FONT> <FONT ID="Void">void</FONT> addReferenceInstruction(<FONT ID="Int">int</FONT> opcode, String type) {
<FONT ID="LN">1541</FONT><A NAME="1541"></A>        <FONT ID="If">if</FONT> (!validTypeDescriptor(type) &amp;&amp; !validInternalForm(type)) {
<FONT ID="LN">1542</FONT><A NAME="1542"></A>            reportEmitterError(<FONT ID="StringLiteral">"%s: '%s' is neither a type descriptor nor in "</FONT>
<FONT ID="LN">1543</FONT><A NAME="1543"></A>                    + <FONT ID="StringLiteral">"internal form"</FONT>, eCurrentMethod, type);
<FONT ID="LN">1544</FONT><A NAME="1544"></A>        }
<FONT ID="LN">1545</FONT><A NAME="1545"></A>        <A HREF="../jminusminus/CLInstruction.java.html">CLInstruction</A> instr = <FONT ID="Null">null</FONT>;
<FONT ID="LN">1546</FONT><A NAME="1546"></A>        <FONT ID="Switch">switch</FONT> (CLInstruction.instructionInfo[opcode].category) {
<FONT ID="LN">1547</FONT><A NAME="1547"></A>        <FONT ID="Case">case</FONT> OBJECT:
<FONT ID="LN">1548</FONT><A NAME="1548"></A>            <FONT ID="Int">int</FONT> index = constantPool.constantClassInfo(type);
<FONT ID="LN">1549</FONT><A NAME="1549"></A>            instr = <FONT ID="New">new</FONT> CLObjectInstruction(opcode, mPC++, index);
<FONT ID="LN">1550</FONT><A NAME="1550"></A>            <FONT ID="Break">break</FONT>;
<FONT ID="LN">1551</FONT><A NAME="1551"></A>        <FONT ID="Default">default</FONT>:
<FONT ID="LN">1552</FONT><A NAME="1552"></A>            reportOpcodeError(opcode);
<FONT ID="LN">1553</FONT><A NAME="1553"></A>        }
<FONT ID="LN">1554</FONT><A NAME="1554"></A>        <FONT ID="If">if</FONT> (instr != <FONT ID="Null">null</FONT>) {
<FONT ID="LN">1555</FONT><A NAME="1555"></A>            mPC += instr.operandCount();
<FONT ID="LN">1556</FONT><A NAME="1556"></A>            mCode.add(instr);
<FONT ID="LN">1557</FONT><A NAME="1557"></A>        }
<FONT ID="LN">1558</FONT><A NAME="1558"></A>    }
<FONT ID="LN">1559</FONT><A NAME="1559"></A>
<FONT ID="LN">1560</FONT><A NAME="1560"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1561</FONT><A NAME="1561"></A>     * Add an array instruction. Following instructions can be added using this
<FONT ID="LN">1562</FONT><A NAME="1562"></A>     * method:
<FONT ID="LN">1563</FONT><A NAME="1563"></A>     * 
<FONT ID="LN">1564</FONT><A NAME="1564"></A>     * &lt;pre&gt;
<FONT ID="LN">1565</FONT><A NAME="1565"></A>     *   NEWARRAY, ANEWARRAY
<FONT ID="LN">1566</FONT><A NAME="1566"></A>     * &lt;/pre&gt;
<FONT ID="LN">1567</FONT><A NAME="1567"></A>     * 
<FONT ID="LN">1568</FONT><A NAME="1568"></A>     * The opcodes for instructions are defined in CLConstants class.
<FONT ID="LN">1569</FONT><A NAME="1569"></A>     * 
<FONT ID="LN">1570</FONT><A NAME="1570"></A>     * @param opcode
<FONT ID="LN">1571</FONT><A NAME="1571"></A>     *            opcode of the instruction.
<FONT ID="LN">1572</FONT><A NAME="1572"></A>     * @param type
<FONT ID="LN">1573</FONT><A NAME="1573"></A>     *            array type. In case of NEWARRAY, the primitive types are
<FONT ID="LN">1574</FONT><A NAME="1574"></A>     *            specified as: "Z" for boolean, "C" for char, "F" for float,
<FONT ID="LN">1575</FONT><A NAME="1575"></A>     *            "D" for double, "B" for byte, "S" for short, "I" for int, "J"
<FONT ID="LN">1576</FONT><A NAME="1576"></A>     *            for long. In case of ANEWARRAY, reference types are specified
<FONT ID="LN">1577</FONT><A NAME="1577"></A>     *            in internal form.
<FONT ID="LN">1578</FONT><A NAME="1578"></A>     */</FONT>
<FONT ID="LN">1579</FONT><A NAME="1579"></A>
<FONT ID="LN">1580</FONT><A NAME="1580"></A>    <FONT ID="Public">public</FONT> <FONT ID="Void">void</FONT> addArrayInstruction(<FONT ID="Int">int</FONT> opcode, String type) {
<FONT ID="LN">1581</FONT><A NAME="1581"></A>        <A HREF="../jminusminus/CLInstruction.java.html">CLInstruction</A> instr = <FONT ID="Null">null</FONT>;
<FONT ID="LN">1582</FONT><A NAME="1582"></A>        <FONT ID="Switch">switch</FONT> (CLInstruction.instructionInfo[opcode].category) {
<FONT ID="LN">1583</FONT><A NAME="1583"></A>        <FONT ID="Case">case</FONT> ARRAY1:
<FONT ID="LN">1584</FONT><A NAME="1584"></A>            <FONT ID="Int">int</FONT> index = <FONT ID="IntegerLiteral">0</FONT>;
<FONT ID="LN">1585</FONT><A NAME="1585"></A>            <FONT ID="If">if</FONT> (opcode == NEWARRAY) {
<FONT ID="LN">1586</FONT><A NAME="1586"></A>                <FONT ID="If">if</FONT> (type.equalsIgnoreCase(<FONT ID="StringLiteral">"Z"</FONT>)) {
<FONT ID="LN">1587</FONT><A NAME="1587"></A>                    index = <FONT ID="IntegerLiteral">4</FONT>;
<FONT ID="LN">1588</FONT><A NAME="1588"></A>                } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (type.equalsIgnoreCase(<FONT ID="StringLiteral">"C"</FONT>)) {
<FONT ID="LN">1589</FONT><A NAME="1589"></A>                    index = <FONT ID="IntegerLiteral">5</FONT>;
<FONT ID="LN">1590</FONT><A NAME="1590"></A>                } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (type.equalsIgnoreCase(<FONT ID="StringLiteral">"F"</FONT>)) {
<FONT ID="LN">1591</FONT><A NAME="1591"></A>                    index = <FONT ID="IntegerLiteral">6</FONT>;
<FONT ID="LN">1592</FONT><A NAME="1592"></A>                } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (type.equalsIgnoreCase(<FONT ID="StringLiteral">"D"</FONT>)) {
<FONT ID="LN">1593</FONT><A NAME="1593"></A>                    index = <FONT ID="IntegerLiteral">7</FONT>;
<FONT ID="LN">1594</FONT><A NAME="1594"></A>                } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (type.equalsIgnoreCase(<FONT ID="StringLiteral">"B"</FONT>)) {
<FONT ID="LN">1595</FONT><A NAME="1595"></A>                    index = <FONT ID="IntegerLiteral">8</FONT>;
<FONT ID="LN">1596</FONT><A NAME="1596"></A>                } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (type.equalsIgnoreCase(<FONT ID="StringLiteral">"S"</FONT>)) {
<FONT ID="LN">1597</FONT><A NAME="1597"></A>                    index = <FONT ID="IntegerLiteral">9</FONT>;
<FONT ID="LN">1598</FONT><A NAME="1598"></A>                } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (type.equalsIgnoreCase(<FONT ID="StringLiteral">"I"</FONT>)) {
<FONT ID="LN">1599</FONT><A NAME="1599"></A>                    index = <FONT ID="IntegerLiteral">10</FONT>;
<FONT ID="LN">1600</FONT><A NAME="1600"></A>                } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (type.equalsIgnoreCase(<FONT ID="StringLiteral">"J"</FONT>)) {
<FONT ID="LN">1601</FONT><A NAME="1601"></A>                    index = <FONT ID="IntegerLiteral">11</FONT>;
<FONT ID="LN">1602</FONT><A NAME="1602"></A>                } <FONT ID="Else">else</FONT> {
<FONT ID="LN">1603</FONT><A NAME="1603"></A>                    reportEmitterError(
<FONT ID="LN">1604</FONT><A NAME="1604"></A>                            <FONT ID="StringLiteral">"%s: '%s' is not a valid primitive type"</FONT>,
<FONT ID="LN">1605</FONT><A NAME="1605"></A>                            eCurrentMethod, type);
<FONT ID="LN">1606</FONT><A NAME="1606"></A>                }
<FONT ID="LN">1607</FONT><A NAME="1607"></A>            } <FONT ID="Else">else</FONT> {
<FONT ID="LN">1608</FONT><A NAME="1608"></A>                <FONT ID="If">if</FONT> (!validTypeDescriptor(type) &amp;&amp; !validInternalForm(type)) {
<FONT ID="LN">1609</FONT><A NAME="1609"></A>                    reportEmitterError(
<FONT ID="LN">1610</FONT><A NAME="1610"></A>                            <FONT ID="StringLiteral">"%s: '%s' is not a valid type descriptor "</FONT>
<FONT ID="LN">1611</FONT><A NAME="1611"></A>                                    + <FONT ID="StringLiteral">"for an array"</FONT>, eCurrentMethod, type);
<FONT ID="LN">1612</FONT><A NAME="1612"></A>                }
<FONT ID="LN">1613</FONT><A NAME="1613"></A>                index = constantPool.constantClassInfo(type);
<FONT ID="LN">1614</FONT><A NAME="1614"></A>            }
<FONT ID="LN">1615</FONT><A NAME="1615"></A>            instr = <FONT ID="New">new</FONT> CLArrayInstruction(opcode, mPC++, index);
<FONT ID="LN">1616</FONT><A NAME="1616"></A>            <FONT ID="Break">break</FONT>;
<FONT ID="LN">1617</FONT><A NAME="1617"></A>        <FONT ID="Default">default</FONT>:
<FONT ID="LN">1618</FONT><A NAME="1618"></A>            reportOpcodeError(opcode);
<FONT ID="LN">1619</FONT><A NAME="1619"></A>        }
<FONT ID="LN">1620</FONT><A NAME="1620"></A>        <FONT ID="If">if</FONT> (instr != <FONT ID="Null">null</FONT>) {
<FONT ID="LN">1621</FONT><A NAME="1621"></A>            mPC += instr.operandCount();
<FONT ID="LN">1622</FONT><A NAME="1622"></A>            mCode.add(instr);
<FONT ID="LN">1623</FONT><A NAME="1623"></A>        }
<FONT ID="LN">1624</FONT><A NAME="1624"></A>    }
<FONT ID="LN">1625</FONT><A NAME="1625"></A>
<FONT ID="LN">1626</FONT><A NAME="1626"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1627</FONT><A NAME="1627"></A>     * Add a MULTIANEWARRAY instruction for creating multi-dimensional arrays.
<FONT ID="LN">1628</FONT><A NAME="1628"></A>     * 
<FONT ID="LN">1629</FONT><A NAME="1629"></A>     * @param type
<FONT ID="LN">1630</FONT><A NAME="1630"></A>     *            array type in internal form.
<FONT ID="LN">1631</FONT><A NAME="1631"></A>     * @param dim
<FONT ID="LN">1632</FONT><A NAME="1632"></A>     *            number of dimensions.
<FONT ID="LN">1633</FONT><A NAME="1633"></A>     */</FONT>
<FONT ID="LN">1634</FONT><A NAME="1634"></A>
<FONT ID="LN">1635</FONT><A NAME="1635"></A>    <FONT ID="Public">public</FONT> <FONT ID="Void">void</FONT> addMULTIANEWARRAYInstruction(String type, <FONT ID="Int">int</FONT> dim) {
<FONT ID="LN">1636</FONT><A NAME="1636"></A>        <A HREF="../jminusminus/CLInstruction.java.html">CLInstruction</A> instr = <FONT ID="Null">null</FONT>;
<FONT ID="LN">1637</FONT><A NAME="1637"></A>        <FONT ID="If">if</FONT> (!validTypeDescriptor(type)) {
<FONT ID="LN">1638</FONT><A NAME="1638"></A>            reportEmitterError(
<FONT ID="LN">1639</FONT><A NAME="1639"></A>                    <FONT ID="StringLiteral">"%s: '%s' is not a valid type descriptor for an array"</FONT>,
<FONT ID="LN">1640</FONT><A NAME="1640"></A>                    eCurrentMethod, type);
<FONT ID="LN">1641</FONT><A NAME="1641"></A>        }
<FONT ID="LN">1642</FONT><A NAME="1642"></A>        <FONT ID="Int">int</FONT> index = constantPool.constantClassInfo(type);
<FONT ID="LN">1643</FONT><A NAME="1643"></A>        instr = <FONT ID="New">new</FONT> CLArrayInstruction(MULTIANEWARRAY, mPC++, index, dim);
<FONT ID="LN">1644</FONT><A NAME="1644"></A>        <FONT ID="If">if</FONT> (instr != <FONT ID="Null">null</FONT>) {
<FONT ID="LN">1645</FONT><A NAME="1645"></A>            mPC += instr.operandCount();
<FONT ID="LN">1646</FONT><A NAME="1646"></A>            mCode.add(instr);
<FONT ID="LN">1647</FONT><A NAME="1647"></A>        }
<FONT ID="LN">1648</FONT><A NAME="1648"></A>    }
<FONT ID="LN">1649</FONT><A NAME="1649"></A>
<FONT ID="LN">1650</FONT><A NAME="1650"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1651</FONT><A NAME="1651"></A>     * Add a branch instruction. Following instructions can be added using this
<FONT ID="LN">1652</FONT><A NAME="1652"></A>     * method:
<FONT ID="LN">1653</FONT><A NAME="1653"></A>     * 
<FONT ID="LN">1654</FONT><A NAME="1654"></A>     * &lt;pre&gt;
<FONT ID="LN">1655</FONT><A NAME="1655"></A>     *   IFEQ, IFNE, IFLT, IFGE, IFGT, IFLE, IF_ICMPEQ, IF_ICMPNE, 
<FONT ID="LN">1656</FONT><A NAME="1656"></A>     *   IF_ICMPLT, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, IF_ACMPEQ, 
<FONT ID="LN">1657</FONT><A NAME="1657"></A>     *   IF_ACMPNE, GOTO, JSR, IF_NULL, IF_NONNULL, GOTO_W, JSR_W
<FONT ID="LN">1658</FONT><A NAME="1658"></A>     * &lt;/pre&gt;
<FONT ID="LN">1659</FONT><A NAME="1659"></A>     * 
<FONT ID="LN">1660</FONT><A NAME="1660"></A>     * The opcodes for instructions are defined in CLConstants class.
<FONT ID="LN">1661</FONT><A NAME="1661"></A>     * 
<FONT ID="LN">1662</FONT><A NAME="1662"></A>     * @param opcode
<FONT ID="LN">1663</FONT><A NAME="1663"></A>     *            opcode of the instruction.
<FONT ID="LN">1664</FONT><A NAME="1664"></A>     * @param label
<FONT ID="LN">1665</FONT><A NAME="1665"></A>     *            branch label.
<FONT ID="LN">1666</FONT><A NAME="1666"></A>     */</FONT>
<FONT ID="LN">1667</FONT><A NAME="1667"></A>
<FONT ID="LN">1668</FONT><A NAME="1668"></A>    <FONT ID="Public">public</FONT> <FONT ID="Void">void</FONT> addBranchInstruction(<FONT ID="Int">int</FONT> opcode, String label) {
<FONT ID="LN">1669</FONT><A NAME="1669"></A>        <A HREF="../jminusminus/CLInstruction.java.html">CLInstruction</A> instr = <FONT ID="Null">null</FONT>;
<FONT ID="LN">1670</FONT><A NAME="1670"></A>        <FONT ID="Switch">switch</FONT> (CLInstruction.instructionInfo[opcode].category) {
<FONT ID="LN">1671</FONT><A NAME="1671"></A>        <FONT ID="Case">case</FONT> FLOW_CONTROL1:
<FONT ID="LN">1672</FONT><A NAME="1672"></A>            instr = <FONT ID="New">new</FONT> CLFlowControlInstruction(opcode, mPC++, label);
<FONT ID="LN">1673</FONT><A NAME="1673"></A>            <FONT ID="Break">break</FONT>;
<FONT ID="LN">1674</FONT><A NAME="1674"></A>        <FONT ID="Default">default</FONT>:
<FONT ID="LN">1675</FONT><A NAME="1675"></A>            reportOpcodeError(opcode);
<FONT ID="LN">1676</FONT><A NAME="1676"></A>        }
<FONT ID="LN">1677</FONT><A NAME="1677"></A>        <FONT ID="If">if</FONT> (instr != <FONT ID="Null">null</FONT>) {
<FONT ID="LN">1678</FONT><A NAME="1678"></A>            mPC += instr.operandCount();
<FONT ID="LN">1679</FONT><A NAME="1679"></A>            mCode.add(instr);
<FONT ID="LN">1680</FONT><A NAME="1680"></A>            mInstructionAfterLabel = <FONT ID="True">true</FONT>;
<FONT ID="LN">1681</FONT><A NAME="1681"></A>        }
<FONT ID="LN">1682</FONT><A NAME="1682"></A>    }
<FONT ID="LN">1683</FONT><A NAME="1683"></A>
<FONT ID="LN">1684</FONT><A NAME="1684"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1685</FONT><A NAME="1685"></A>     * Add a TABLESWITCH instruction -- used for switch statements.
<FONT ID="LN">1686</FONT><A NAME="1686"></A>     * 
<FONT ID="LN">1687</FONT><A NAME="1687"></A>     * @param defaultLabel
<FONT ID="LN">1688</FONT><A NAME="1688"></A>     *            jump label for default value.
<FONT ID="LN">1689</FONT><A NAME="1689"></A>     * @param low
<FONT ID="LN">1690</FONT><A NAME="1690"></A>     *            smallest value of index.
<FONT ID="LN">1691</FONT><A NAME="1691"></A>     * @param high
<FONT ID="LN">1692</FONT><A NAME="1692"></A>     *            highest value of index.
<FONT ID="LN">1693</FONT><A NAME="1693"></A>     * @param labels
<FONT ID="LN">1694</FONT><A NAME="1694"></A>     *            list of jump labels for each index value from low to high, end
<FONT ID="LN">1695</FONT><A NAME="1695"></A>     *            values included.
<FONT ID="LN">1696</FONT><A NAME="1696"></A>     */</FONT>
<FONT ID="LN">1697</FONT><A NAME="1697"></A>
<FONT ID="LN">1698</FONT><A NAME="1698"></A>    <FONT ID="Public">public</FONT> <FONT ID="Void">void</FONT> addTABLESWITCHInstruction(String defaultLabel, <FONT ID="Int">int</FONT> low,
<FONT ID="LN">1699</FONT><A NAME="1699"></A>            <FONT ID="Int">int</FONT> high, ArrayList&lt;String&gt; labels) {
<FONT ID="LN">1700</FONT><A NAME="1700"></A>        CLFlowControlInstruction instr = <FONT ID="New">new</FONT> CLFlowControlInstruction(
<FONT ID="LN">1701</FONT><A NAME="1701"></A>                TABLESWITCH, mPC++, defaultLabel, low, high, labels);
<FONT ID="LN">1702</FONT><A NAME="1702"></A>        mPC += instr.operandCount();
<FONT ID="LN">1703</FONT><A NAME="1703"></A>        mCode.add(instr);
<FONT ID="LN">1704</FONT><A NAME="1704"></A>        mInstructionAfterLabel = <FONT ID="True">true</FONT>;
<FONT ID="LN">1705</FONT><A NAME="1705"></A>    }
<FONT ID="LN">1706</FONT><A NAME="1706"></A>
<FONT ID="LN">1707</FONT><A NAME="1707"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1708</FONT><A NAME="1708"></A>     * Add a LOOKUPSWITCH instruction -- used for switch statements.
<FONT ID="LN">1709</FONT><A NAME="1709"></A>     * 
<FONT ID="LN">1710</FONT><A NAME="1710"></A>     * @param defaultLabel
<FONT ID="LN">1711</FONT><A NAME="1711"></A>     *            jump label for default value.
<FONT ID="LN">1712</FONT><A NAME="1712"></A>     * @param numPairs
<FONT ID="LN">1713</FONT><A NAME="1713"></A>     *            number of pairs in the match table.
<FONT ID="LN">1714</FONT><A NAME="1714"></A>     * @param matchLabelPairs
<FONT ID="LN">1715</FONT><A NAME="1715"></A>     *            key match table.
<FONT ID="LN">1716</FONT><A NAME="1716"></A>     */</FONT>
<FONT ID="LN">1717</FONT><A NAME="1717"></A>
<FONT ID="LN">1718</FONT><A NAME="1718"></A>    <FONT ID="Public">public</FONT> <FONT ID="Void">void</FONT> addLOOKUPSWITCHInstruction(String defaultLabel, <FONT ID="Int">int</FONT> numPairs,
<FONT ID="LN">1719</FONT><A NAME="1719"></A>            TreeMap&lt;Integer, String&gt; matchLabelPairs) {
<FONT ID="LN">1720</FONT><A NAME="1720"></A>        CLFlowControlInstruction instr = <FONT ID="New">new</FONT> CLFlowControlInstruction(
<FONT ID="LN">1721</FONT><A NAME="1721"></A>                LOOKUPSWITCH, mPC++, defaultLabel, numPairs, matchLabelPairs);
<FONT ID="LN">1722</FONT><A NAME="1722"></A>        mPC += instr.operandCount();
<FONT ID="LN">1723</FONT><A NAME="1723"></A>        mCode.add(instr);
<FONT ID="LN">1724</FONT><A NAME="1724"></A>        mInstructionAfterLabel = <FONT ID="True">true</FONT>;
<FONT ID="LN">1725</FONT><A NAME="1725"></A>    }
<FONT ID="LN">1726</FONT><A NAME="1726"></A>
<FONT ID="LN">1727</FONT><A NAME="1727"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1728</FONT><A NAME="1728"></A>     * Add an LDC instruction to load an int constant on the operand stack.
<FONT ID="LN">1729</FONT><A NAME="1729"></A>     * 
<FONT ID="LN">1730</FONT><A NAME="1730"></A>     * @param i
<FONT ID="LN">1731</FONT><A NAME="1731"></A>     *            int constant.
<FONT ID="LN">1732</FONT><A NAME="1732"></A>     */</FONT>
<FONT ID="LN">1733</FONT><A NAME="1733"></A>
<FONT ID="LN">1734</FONT><A NAME="1734"></A>    <FONT ID="Public">public</FONT> <FONT ID="Void">void</FONT> addLDCInstruction(<FONT ID="Int">int</FONT> i) {
<FONT ID="LN">1735</FONT><A NAME="1735"></A>        ldcInstruction(constantPool.constantIntegerInfo(i));
<FONT ID="LN">1736</FONT><A NAME="1736"></A>    }
<FONT ID="LN">1737</FONT><A NAME="1737"></A>
<FONT ID="LN">1738</FONT><A NAME="1738"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1739</FONT><A NAME="1739"></A>     * Add an LDC instruction to load a float constant on the operand stack.
<FONT ID="LN">1740</FONT><A NAME="1740"></A>     * 
<FONT ID="LN">1741</FONT><A NAME="1741"></A>     * @param f
<FONT ID="LN">1742</FONT><A NAME="1742"></A>     *            float constant.
<FONT ID="LN">1743</FONT><A NAME="1743"></A>     */</FONT>
<FONT ID="LN">1744</FONT><A NAME="1744"></A>
<FONT ID="LN">1745</FONT><A NAME="1745"></A>    <FONT ID="Public">public</FONT> <FONT ID="Void">void</FONT> addLDCInstruction(<FONT ID="Float">float</FONT> f) {
<FONT ID="LN">1746</FONT><A NAME="1746"></A>        ldcInstruction(constantPool.constantFloatInfo(f));
<FONT ID="LN">1747</FONT><A NAME="1747"></A>    }
<FONT ID="LN">1748</FONT><A NAME="1748"></A>
<FONT ID="LN">1749</FONT><A NAME="1749"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1750</FONT><A NAME="1750"></A>     * Add an LDC instruction to load a long constant on the operand stack.
<FONT ID="LN">1751</FONT><A NAME="1751"></A>     * 
<FONT ID="LN">1752</FONT><A NAME="1752"></A>     * @param l
<FONT ID="LN">1753</FONT><A NAME="1753"></A>     *            long constant.
<FONT ID="LN">1754</FONT><A NAME="1754"></A>     */</FONT>
<FONT ID="LN">1755</FONT><A NAME="1755"></A>
<FONT ID="LN">1756</FONT><A NAME="1756"></A>    <FONT ID="Public">public</FONT> <FONT ID="Void">void</FONT> addLDCInstruction(<FONT ID="Long">long</FONT> l) {
<FONT ID="LN">1757</FONT><A NAME="1757"></A>        ldc2wInstruction(constantPool.constantLongInfo(l));
<FONT ID="LN">1758</FONT><A NAME="1758"></A>    }
<FONT ID="LN">1759</FONT><A NAME="1759"></A>
<FONT ID="LN">1760</FONT><A NAME="1760"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1761</FONT><A NAME="1761"></A>     * Add an LDC instruction to load a double constant on the operand stack.
<FONT ID="LN">1762</FONT><A NAME="1762"></A>     * 
<FONT ID="LN">1763</FONT><A NAME="1763"></A>     * @param d
<FONT ID="LN">1764</FONT><A NAME="1764"></A>     *            double constant.
<FONT ID="LN">1765</FONT><A NAME="1765"></A>     */</FONT>
<FONT ID="LN">1766</FONT><A NAME="1766"></A>
<FONT ID="LN">1767</FONT><A NAME="1767"></A>    <FONT ID="Public">public</FONT> <FONT ID="Void">void</FONT> addLDCInstruction(<FONT ID="Double">double</FONT> d) {
<FONT ID="LN">1768</FONT><A NAME="1768"></A>        ldc2wInstruction(constantPool.constantDoubleInfo(d));
<FONT ID="LN">1769</FONT><A NAME="1769"></A>    }
<FONT ID="LN">1770</FONT><A NAME="1770"></A>
<FONT ID="LN">1771</FONT><A NAME="1771"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1772</FONT><A NAME="1772"></A>     * Add an LDC instruction to load a String constant on the operand stack.
<FONT ID="LN">1773</FONT><A NAME="1773"></A>     * 
<FONT ID="LN">1774</FONT><A NAME="1774"></A>     * @param s
<FONT ID="LN">1775</FONT><A NAME="1775"></A>     *            String constant.
<FONT ID="LN">1776</FONT><A NAME="1776"></A>     */</FONT>
<FONT ID="LN">1777</FONT><A NAME="1777"></A>
<FONT ID="LN">1778</FONT><A NAME="1778"></A>    <FONT ID="Public">public</FONT> <FONT ID="Void">void</FONT> addLDCInstruction(String s) {
<FONT ID="LN">1779</FONT><A NAME="1779"></A>        ldcInstruction(constantPool.constantStringInfo(s));
<FONT ID="LN">1780</FONT><A NAME="1780"></A>    }
<FONT ID="LN">1781</FONT><A NAME="1781"></A>
<FONT ID="LN">1782</FONT><A NAME="1782"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1783</FONT><A NAME="1783"></A>     * Add the specified class attribute to the attribyte section of the class.
<FONT ID="LN">1784</FONT><A NAME="1784"></A>     * 
<FONT ID="LN">1785</FONT><A NAME="1785"></A>     * @param attribute
<FONT ID="LN">1786</FONT><A NAME="1786"></A>     *            class attribute.
<FONT ID="LN">1787</FONT><A NAME="1787"></A>     */</FONT>
<FONT ID="LN">1788</FONT><A NAME="1788"></A>
<FONT ID="LN">1789</FONT><A NAME="1789"></A>    <FONT ID="Public">public</FONT> <FONT ID="Void">void</FONT> addClassAttribute(<A HREF="../jminusminus/CLAttributeInfo.java.html">CLAttributeInfo</A> attribute) {
<FONT ID="LN">1790</FONT><A NAME="1790"></A>        <FONT ID="If">if</FONT> (attributes != <FONT ID="Null">null</FONT>) {
<FONT ID="LN">1791</FONT><A NAME="1791"></A>            attributes.add(attribute);
<FONT ID="LN">1792</FONT><A NAME="1792"></A>        }
<FONT ID="LN">1793</FONT><A NAME="1793"></A>    }
<FONT ID="LN">1794</FONT><A NAME="1794"></A>
<FONT ID="LN">1795</FONT><A NAME="1795"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1796</FONT><A NAME="1796"></A>     * Add the specified method attribute to the attribute section of the method
<FONT ID="LN">1797</FONT><A NAME="1797"></A>     * last added.
<FONT ID="LN">1798</FONT><A NAME="1798"></A>     * 
<FONT ID="LN">1799</FONT><A NAME="1799"></A>     * @param attribute
<FONT ID="LN">1800</FONT><A NAME="1800"></A>     *            method attribute.
<FONT ID="LN">1801</FONT><A NAME="1801"></A>     */</FONT>
<FONT ID="LN">1802</FONT><A NAME="1802"></A>
<FONT ID="LN">1803</FONT><A NAME="1803"></A>    <FONT ID="Public">public</FONT> <FONT ID="Void">void</FONT> addMethodAttribute(<A HREF="../jminusminus/CLAttributeInfo.java.html">CLAttributeInfo</A> attribute) {
<FONT ID="LN">1804</FONT><A NAME="1804"></A>        <FONT ID="If">if</FONT> (mAttributes != <FONT ID="Null">null</FONT>) {
<FONT ID="LN">1805</FONT><A NAME="1805"></A>            mAttributes.add(attribute);
<FONT ID="LN">1806</FONT><A NAME="1806"></A>        }
<FONT ID="LN">1807</FONT><A NAME="1807"></A>    }
<FONT ID="LN">1808</FONT><A NAME="1808"></A>
<FONT ID="LN">1809</FONT><A NAME="1809"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1810</FONT><A NAME="1810"></A>     * Add the specified field attribute the attribute section of the field last
<FONT ID="LN">1811</FONT><A NAME="1811"></A>     * added.
<FONT ID="LN">1812</FONT><A NAME="1812"></A>     * 
<FONT ID="LN">1813</FONT><A NAME="1813"></A>     * @param attribute
<FONT ID="LN">1814</FONT><A NAME="1814"></A>     *            field attribute.
<FONT ID="LN">1815</FONT><A NAME="1815"></A>     */</FONT>
<FONT ID="LN">1816</FONT><A NAME="1816"></A>
<FONT ID="LN">1817</FONT><A NAME="1817"></A>    <FONT ID="Public">public</FONT> <FONT ID="Void">void</FONT> addFieldAttribute(<A HREF="../jminusminus/CLAttributeInfo.java.html">CLAttributeInfo</A> attribute) {
<FONT ID="LN">1818</FONT><A NAME="1818"></A>        <FONT ID="If">if</FONT> (fAttributes != <FONT ID="Null">null</FONT>) {
<FONT ID="LN">1819</FONT><A NAME="1819"></A>            fAttributes.add(attribute);
<FONT ID="LN">1820</FONT><A NAME="1820"></A>        }
<FONT ID="LN">1821</FONT><A NAME="1821"></A>    }
<FONT ID="LN">1822</FONT><A NAME="1822"></A>
<FONT ID="LN">1823</FONT><A NAME="1823"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1824</FONT><A NAME="1824"></A>     * Add the specified code attribute to the attribute section of the code for
<FONT ID="LN">1825</FONT><A NAME="1825"></A>     * the method last added.
<FONT ID="LN">1826</FONT><A NAME="1826"></A>     * 
<FONT ID="LN">1827</FONT><A NAME="1827"></A>     * @param attribute
<FONT ID="LN">1828</FONT><A NAME="1828"></A>     *            code attribute.
<FONT ID="LN">1829</FONT><A NAME="1829"></A>     */</FONT>
<FONT ID="LN">1830</FONT><A NAME="1830"></A>
<FONT ID="LN">1831</FONT><A NAME="1831"></A>    <FONT ID="Public">public</FONT> <FONT ID="Void">void</FONT> addCodeAttribute(<A HREF="../jminusminus/CLAttributeInfo.java.html">CLAttributeInfo</A> attribute) {
<FONT ID="LN">1832</FONT><A NAME="1832"></A>        <FONT ID="If">if</FONT> (mCodeAttributes != <FONT ID="Null">null</FONT>) {
<FONT ID="LN">1833</FONT><A NAME="1833"></A>            mCodeAttributes.add(attribute);
<FONT ID="LN">1834</FONT><A NAME="1834"></A>        }
<FONT ID="LN">1835</FONT><A NAME="1835"></A>    }
<FONT ID="LN">1836</FONT><A NAME="1836"></A>
<FONT ID="LN">1837</FONT><A NAME="1837"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1838</FONT><A NAME="1838"></A>     * Add a jump label to the code section of the method being added. A flow
<FONT ID="LN">1839</FONT><A NAME="1839"></A>     * control instruction that was added with this label will jump to the
<FONT ID="LN">1840</FONT><A NAME="1840"></A>     * instruction right after the label.
<FONT ID="LN">1841</FONT><A NAME="1841"></A>     * 
<FONT ID="LN">1842</FONT><A NAME="1842"></A>     * @param label
<FONT ID="LN">1843</FONT><A NAME="1843"></A>     *            jump label.
<FONT ID="LN">1844</FONT><A NAME="1844"></A>     */</FONT>
<FONT ID="LN">1845</FONT><A NAME="1845"></A>
<FONT ID="LN">1846</FONT><A NAME="1846"></A>    <FONT ID="Public">public</FONT> <FONT ID="Void">void</FONT> addLabel(String label) {
<FONT ID="LN">1847</FONT><A NAME="1847"></A>        mLabels.put(label, mPC);
<FONT ID="LN">1848</FONT><A NAME="1848"></A>        mInstructionAfterLabel = <FONT ID="False">false</FONT>;
<FONT ID="LN">1849</FONT><A NAME="1849"></A>    }
<FONT ID="LN">1850</FONT><A NAME="1850"></A>
<FONT ID="LN">1851</FONT><A NAME="1851"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1852</FONT><A NAME="1852"></A>     * Construct and return a unique jump label.
<FONT ID="LN">1853</FONT><A NAME="1853"></A>     * 
<FONT ID="LN">1854</FONT><A NAME="1854"></A>     * @return unique jump label.
<FONT ID="LN">1855</FONT><A NAME="1855"></A>     */</FONT>
<FONT ID="LN">1856</FONT><A NAME="1856"></A>
<FONT ID="LN">1857</FONT><A NAME="1857"></A>    <FONT ID="Public">public</FONT> String createLabel() {
<FONT ID="LN">1858</FONT><A NAME="1858"></A>        <FONT ID="Return">return</FONT> <FONT ID="StringLiteral">"Label"</FONT> + mLabelCount++;
<FONT ID="LN">1859</FONT><A NAME="1859"></A>    }
<FONT ID="LN">1860</FONT><A NAME="1860"></A>
<FONT ID="LN">1861</FONT><A NAME="1861"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1862</FONT><A NAME="1862"></A>     * Return the pc (location counter). The next instruction will be added with
<FONT ID="LN">1863</FONT><A NAME="1863"></A>     * this pc.
<FONT ID="LN">1864</FONT><A NAME="1864"></A>     * 
<FONT ID="LN">1865</FONT><A NAME="1865"></A>     * @return the pc.
<FONT ID="LN">1866</FONT><A NAME="1866"></A>     */</FONT>
<FONT ID="LN">1867</FONT><A NAME="1867"></A>
<FONT ID="LN">1868</FONT><A NAME="1868"></A>    <FONT ID="Public">public</FONT> <FONT ID="Int">int</FONT> pc() {
<FONT ID="LN">1869</FONT><A NAME="1869"></A>        <FONT ID="Return">return</FONT> mPC;
<FONT ID="LN">1870</FONT><A NAME="1870"></A>    }
<FONT ID="LN">1871</FONT><A NAME="1871"></A>
<FONT ID="LN">1872</FONT><A NAME="1872"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1873</FONT><A NAME="1873"></A>     * Return the constant pool of the class being built.
<FONT ID="LN">1874</FONT><A NAME="1874"></A>     * 
<FONT ID="LN">1875</FONT><A NAME="1875"></A>     * @return constant pool.
<FONT ID="LN">1876</FONT><A NAME="1876"></A>     */</FONT>
<FONT ID="LN">1877</FONT><A NAME="1877"></A>
<FONT ID="LN">1878</FONT><A NAME="1878"></A>    <FONT ID="Public">public</FONT> <A HREF="../jminusminus/CLConstantPool.java.html">CLConstantPool</A> constantPool() {
<FONT ID="LN">1879</FONT><A NAME="1879"></A>        <FONT ID="Return">return</FONT> constantPool;
<FONT ID="LN">1880</FONT><A NAME="1880"></A>    }
<FONT ID="LN">1881</FONT><A NAME="1881"></A>
<FONT ID="LN">1882</FONT><A NAME="1882"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1883</FONT><A NAME="1883"></A>     * Set a new ByteClassLoader for loading classes from byte streams.
<FONT ID="LN">1884</FONT><A NAME="1884"></A>     */</FONT>
<FONT ID="LN">1885</FONT><A NAME="1885"></A>
<FONT ID="LN">1886</FONT><A NAME="1886"></A>    <FONT ID="Public">public</FONT> <FONT ID="Static">static</FONT> <FONT ID="Void">void</FONT> initializeByteClassLoader() {
<FONT ID="LN">1887</FONT><A NAME="1887"></A>        byteClassLoader = <FONT ID="New">new</FONT> ByteClassLoader();
<FONT ID="LN">1888</FONT><A NAME="1888"></A>    }
<FONT ID="LN">1889</FONT><A NAME="1889"></A>
<FONT ID="LN">1890</FONT><A NAME="1890"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1891</FONT><A NAME="1891"></A>     * Return the CLFile instance corresponding to the class built by this
<FONT ID="LN">1892</FONT><A NAME="1892"></A>     * emitter.
<FONT ID="LN">1893</FONT><A NAME="1893"></A>     */</FONT>
<FONT ID="LN">1894</FONT><A NAME="1894"></A>
<FONT ID="LN">1895</FONT><A NAME="1895"></A>    <FONT ID="Public">public</FONT> <A HREF="../jminusminus/CLFile.java.html">CLFile</A> clFile() {
<FONT ID="LN">1896</FONT><A NAME="1896"></A>        <FONT ID="Return">return</FONT> clFile;
<FONT ID="LN">1897</FONT><A NAME="1897"></A>    }
<FONT ID="LN">1898</FONT><A NAME="1898"></A>
<FONT ID="LN">1899</FONT><A NAME="1899"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1900</FONT><A NAME="1900"></A>     * Return the class being constructed as a Java Class instance.
<FONT ID="LN">1901</FONT><A NAME="1901"></A>     * 
<FONT ID="LN">1902</FONT><A NAME="1902"></A>     * @return Java Class instance.
<FONT ID="LN">1903</FONT><A NAME="1903"></A>     */</FONT>
<FONT ID="LN">1904</FONT><A NAME="1904"></A>    <FONT ID="Public">public</FONT> Class toClass() {
<FONT ID="LN">1905</FONT><A NAME="1905"></A>        endOpenMethodIfAny();
<FONT ID="LN">1906</FONT><A NAME="1906"></A>        Class theClass = <FONT ID="Null">null</FONT>;
<FONT ID="LN">1907</FONT><A NAME="1907"></A>        <FONT ID="Try">try</FONT> {
<FONT ID="LN">1908</FONT><A NAME="1908"></A>            <FONT ID="SingleLineComment">// Extract the bytes from the class representation in
<FONT ID="LN">1909</FONT><A NAME="1909"></A></FONT>            <FONT ID="SingleLineComment">// memory into an array of bytes
<FONT ID="LN">1910</FONT><A NAME="1910"></A></FONT>            ByteArrayOutputStream byteStream = <FONT ID="New">new</FONT> ByteArrayOutputStream();
<FONT ID="LN">1911</FONT><A NAME="1911"></A>            CLOutputStream out = <FONT ID="New">new</FONT> CLOutputStream(<FONT ID="New">new</FONT> BufferedOutputStream(
<FONT ID="LN">1912</FONT><A NAME="1912"></A>                    byteStream));
<FONT ID="LN">1913</FONT><A NAME="1913"></A>            clFile.write(out);
<FONT ID="LN">1914</FONT><A NAME="1914"></A>            out.close();
<FONT ID="LN">1915</FONT><A NAME="1915"></A>            <FONT ID="Byte">byte</FONT>[] classBytes = byteStream.toByteArray();
<FONT ID="LN">1916</FONT><A NAME="1916"></A>            byteStream.close();
<FONT ID="LN">1917</FONT><A NAME="1917"></A>
<FONT ID="LN">1918</FONT><A NAME="1918"></A>            <FONT ID="SingleLineComment">// Load a Java Class instance from its byte
<FONT ID="LN">1919</FONT><A NAME="1919"></A></FONT>            <FONT ID="SingleLineComment">// representation
<FONT ID="LN">1920</FONT><A NAME="1920"></A></FONT>            byteClassLoader.setClassBytes(classBytes);
<FONT ID="LN">1921</FONT><A NAME="1921"></A>            theClass = byteClassLoader.loadClass(name, <FONT ID="True">true</FONT>);
<FONT ID="LN">1922</FONT><A NAME="1922"></A>        } <FONT ID="Catch">catch</FONT> (IOException e) {
<FONT ID="LN">1923</FONT><A NAME="1923"></A>            reportEmitterError(<FONT ID="StringLiteral">"Cannot write class to byte stream"</FONT>);
<FONT ID="LN">1924</FONT><A NAME="1924"></A>        } <FONT ID="Catch">catch</FONT> (ClassNotFoundException e) {
<FONT ID="LN">1925</FONT><A NAME="1925"></A>            reportEmitterError(<FONT ID="StringLiteral">"Cannot load class from byte stream"</FONT>);
<FONT ID="LN">1926</FONT><A NAME="1926"></A>        }
<FONT ID="LN">1927</FONT><A NAME="1927"></A>        <FONT ID="Return">return</FONT> theClass;
<FONT ID="LN">1928</FONT><A NAME="1928"></A>    }
<FONT ID="LN">1929</FONT><A NAME="1929"></A>
<FONT ID="LN">1930</FONT><A NAME="1930"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1931</FONT><A NAME="1931"></A>     * Write out the class to the file system as a .class file if toFile is
<FONT ID="LN">1932</FONT><A NAME="1932"></A>     * true. The destination directory for the file can be set using the
<FONT ID="LN">1933</FONT><A NAME="1933"></A>     * destinationDir(String dir) method.
<FONT ID="LN">1934</FONT><A NAME="1934"></A>     */</FONT>
<FONT ID="LN">1935</FONT><A NAME="1935"></A>
<FONT ID="LN">1936</FONT><A NAME="1936"></A>    <FONT ID="Public">public</FONT> <FONT ID="Void">void</FONT> write() {
<FONT ID="LN">1937</FONT><A NAME="1937"></A>        endOpenMethodIfAny();
<FONT ID="LN">1938</FONT><A NAME="1938"></A>        <FONT ID="If">if</FONT> (!toFile) {
<FONT ID="LN">1939</FONT><A NAME="1939"></A>            <FONT ID="Return">return</FONT>;
<FONT ID="LN">1940</FONT><A NAME="1940"></A>        }
<FONT ID="LN">1941</FONT><A NAME="1941"></A>        String outFile = destDir + File.separator + name + <FONT ID="StringLiteral">".class"</FONT>;
<FONT ID="LN">1942</FONT><A NAME="1942"></A>        <FONT ID="Try">try</FONT> {
<FONT ID="LN">1943</FONT><A NAME="1943"></A>            File file = <FONT ID="New">new</FONT> File(destDir + File.separator
<FONT ID="LN">1944</FONT><A NAME="1944"></A>                    + name.substring(<FONT ID="IntegerLiteral">0</FONT>, name.lastIndexOf(<FONT ID="StringLiteral">"/"</FONT>) + <FONT ID="IntegerLiteral">1</FONT>));
<FONT ID="LN">1945</FONT><A NAME="1945"></A>            file.mkdirs();
<FONT ID="LN">1946</FONT><A NAME="1946"></A>            CLOutputStream out = <FONT ID="New">new</FONT> CLOutputStream(<FONT ID="New">new</FONT> BufferedOutputStream(
<FONT ID="LN">1947</FONT><A NAME="1947"></A>                    <FONT ID="New">new</FONT> FileOutputStream(outFile)));
<FONT ID="LN">1948</FONT><A NAME="1948"></A>            clFile.write(out);
<FONT ID="LN">1949</FONT><A NAME="1949"></A>            out.close();
<FONT ID="LN">1950</FONT><A NAME="1950"></A>        } <FONT ID="Catch">catch</FONT> (FileNotFoundException e) {
<FONT ID="LN">1951</FONT><A NAME="1951"></A>            reportEmitterError(<FONT ID="StringLiteral">"File %s not found"</FONT>, outFile);
<FONT ID="LN">1952</FONT><A NAME="1952"></A>        } <FONT ID="Catch">catch</FONT> (IOException e) {
<FONT ID="LN">1953</FONT><A NAME="1953"></A>            reportEmitterError(<FONT ID="StringLiteral">"Cannot write to file %s"</FONT>, outFile);
<FONT ID="LN">1954</FONT><A NAME="1954"></A>        }
<FONT ID="LN">1955</FONT><A NAME="1955"></A>    }
<FONT ID="LN">1956</FONT><A NAME="1956"></A>}
<FONT ID="LN">1957</FONT><A NAME="1957"></A>
<FONT ID="LN">1958</FONT><A NAME="1958"></A><FONT ID="FormalComment">/**
<FONT ID="LN">1959</FONT><A NAME="1959"></A> * Representation of an exception handler.
<FONT ID="LN">1960</FONT><A NAME="1960"></A> */</FONT>
<FONT ID="LN">1961</FONT><A NAME="1961"></A>
<FONT ID="LN">1962</FONT><A NAME="1962"></A><FONT ID="Class">class</FONT> CLException {
<FONT ID="LN">1963</FONT><A NAME="1963"></A>
<FONT ID="LN">1964</FONT><A NAME="1964"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1965</FONT><A NAME="1965"></A>     * The exception handler is active from this instruction in the code section
<FONT ID="LN">1966</FONT><A NAME="1966"></A>     * of the current method being added to ...
<FONT ID="LN">1967</FONT><A NAME="1967"></A>     */</FONT>
<FONT ID="LN">1968</FONT><A NAME="1968"></A>    <FONT ID="Public">public</FONT> String startLabel;
<FONT ID="LN">1969</FONT><A NAME="1969"></A>
<FONT ID="LN">1970</FONT><A NAME="1970"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1971</FONT><A NAME="1971"></A>     * this instruction. Formally, the handler is active while the program
<FONT ID="LN">1972</FONT><A NAME="1972"></A>     * counter is within the interval [startPC, endPC).
<FONT ID="LN">1973</FONT><A NAME="1973"></A>     */</FONT>
<FONT ID="LN">1974</FONT><A NAME="1974"></A>    <FONT ID="Public">public</FONT> String endLabel;
<FONT ID="LN">1975</FONT><A NAME="1975"></A>
<FONT ID="LN">1976</FONT><A NAME="1976"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1977</FONT><A NAME="1977"></A>     * Instruction after this label is first instruction of the handler.
<FONT ID="LN">1978</FONT><A NAME="1978"></A>     */</FONT>
<FONT ID="LN">1979</FONT><A NAME="1979"></A>    <FONT ID="Public">public</FONT> String handlerLabel;
<FONT ID="LN">1980</FONT><A NAME="1980"></A>
<FONT ID="LN">1981</FONT><A NAME="1981"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1982</FONT><A NAME="1982"></A>     * The class of exceptions that this exception handler is designated to
<FONT ID="LN">1983</FONT><A NAME="1983"></A>     * catch.
<FONT ID="LN">1984</FONT><A NAME="1984"></A>     */</FONT>
<FONT ID="LN">1985</FONT><A NAME="1985"></A>    <FONT ID="Public">public</FONT> String catchType;
<FONT ID="LN">1986</FONT><A NAME="1986"></A>
<FONT ID="LN">1987</FONT><A NAME="1987"></A>    <FONT ID="FormalComment">/** startLabel is resolved to this value. */</FONT>
<FONT ID="LN">1988</FONT><A NAME="1988"></A>    <FONT ID="Public">public</FONT> <FONT ID="Int">int</FONT> startPC;
<FONT ID="LN">1989</FONT><A NAME="1989"></A>
<FONT ID="LN">1990</FONT><A NAME="1990"></A>    <FONT ID="FormalComment">/** endLabel is resolved to this value. */</FONT>
<FONT ID="LN">1991</FONT><A NAME="1991"></A>    <FONT ID="Public">public</FONT> <FONT ID="Int">int</FONT> endPC;
<FONT ID="LN">1992</FONT><A NAME="1992"></A>
<FONT ID="LN">1993</FONT><A NAME="1993"></A>    <FONT ID="FormalComment">/** handlerLabel is resolved to this value. */</FONT>
<FONT ID="LN">1994</FONT><A NAME="1994"></A>    <FONT ID="Public">public</FONT> <FONT ID="Int">int</FONT> handlerPC;
<FONT ID="LN">1995</FONT><A NAME="1995"></A>
<FONT ID="LN">1996</FONT><A NAME="1996"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1997</FONT><A NAME="1997"></A>     * Construct a CLException object.
<FONT ID="LN">1998</FONT><A NAME="1998"></A>     * 
<FONT ID="LN">1999</FONT><A NAME="1999"></A>     * @param startLabel
<FONT ID="LN">2000</FONT><A NAME="2000"></A>     *            the exception handler is active from the instruction following
<FONT ID="LN">2001</FONT><A NAME="2001"></A>     *            this label in the code section of the current method being
<FONT ID="LN">2002</FONT><A NAME="2002"></A>     *            added ...
<FONT ID="LN">2003</FONT><A NAME="2003"></A>     * @param endLabel
<FONT ID="LN">2004</FONT><A NAME="2004"></A>     *            to the instruction following this label. Formally, the handler
<FONT ID="LN">2005</FONT><A NAME="2005"></A>     *            is active while the program counter is within the interval
<FONT ID="LN">2006</FONT><A NAME="2006"></A>     *            [startLabel, endLabel).
<FONT ID="LN">2007</FONT><A NAME="2007"></A>     * @param handlerLabel
<FONT ID="LN">2008</FONT><A NAME="2008"></A>     *            the handler begins with instruction following this label.
<FONT ID="LN">2009</FONT><A NAME="2009"></A>     * @param catchType
<FONT ID="LN">2010</FONT><A NAME="2010"></A>     *            the exception type that this exception handler is designated
<FONT ID="LN">2011</FONT><A NAME="2011"></A>     *            to catch, as a fully qualified name in internal form.
<FONT ID="LN">2012</FONT><A NAME="2012"></A>     */</FONT>
<FONT ID="LN">2013</FONT><A NAME="2013"></A>
<FONT ID="LN">2014</FONT><A NAME="2014"></A>    <FONT ID="Public">public</FONT> CLException(String startLabel, String endLabel, String handlerLabel,
<FONT ID="LN">2015</FONT><A NAME="2015"></A>            String catchType) {
<FONT ID="LN">2016</FONT><A NAME="2016"></A>        <FONT ID="This">this</FONT>.startLabel = startLabel;
<FONT ID="LN">2017</FONT><A NAME="2017"></A>        <FONT ID="This">this</FONT>.endLabel = endLabel;
<FONT ID="LN">2018</FONT><A NAME="2018"></A>        <FONT ID="This">this</FONT>.handlerLabel = handlerLabel;
<FONT ID="LN">2019</FONT><A NAME="2019"></A>        <FONT ID="This">this</FONT>.catchType = catchType;
<FONT ID="LN">2020</FONT><A NAME="2020"></A>    }
<FONT ID="LN">2021</FONT><A NAME="2021"></A>
<FONT ID="LN">2022</FONT><A NAME="2022"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">2023</FONT><A NAME="2023"></A>     * Resolve the jump labels to the corresponding pc values using the given
<FONT ID="LN">2024</FONT><A NAME="2024"></A>     * label to pc mapping. If unable to resolve a label, the corresponding pc
<FONT ID="LN">2025</FONT><A NAME="2025"></A>     * is set to 0.
<FONT ID="LN">2026</FONT><A NAME="2026"></A>     * 
<FONT ID="LN">2027</FONT><A NAME="2027"></A>     * @param labelToPC
<FONT ID="LN">2028</FONT><A NAME="2028"></A>     *            label to pc mapping.
<FONT ID="LN">2029</FONT><A NAME="2029"></A>     * @return true if all labels were resolved successfully; false otherwise.
<FONT ID="LN">2030</FONT><A NAME="2030"></A>     */</FONT>
<FONT ID="LN">2031</FONT><A NAME="2031"></A>
<FONT ID="LN">2032</FONT><A NAME="2032"></A>    <FONT ID="Public">public</FONT> <FONT ID="Boolean">boolean</FONT> resolveLabels(Hashtable&lt;String, Integer&gt; labelToPC) {
<FONT ID="LN">2033</FONT><A NAME="2033"></A>        <FONT ID="Boolean">boolean</FONT> allLabelsResolved = <FONT ID="True">true</FONT>;
<FONT ID="LN">2034</FONT><A NAME="2034"></A>        <FONT ID="If">if</FONT> (labelToPC.containsKey(startLabel)) {
<FONT ID="LN">2035</FONT><A NAME="2035"></A>            startPC = labelToPC.get(startLabel);
<FONT ID="LN">2036</FONT><A NAME="2036"></A>        } <FONT ID="Else">else</FONT> {
<FONT ID="LN">2037</FONT><A NAME="2037"></A>            startPC = <FONT ID="IntegerLiteral">0</FONT>;
<FONT ID="LN">2038</FONT><A NAME="2038"></A>            allLabelsResolved = <FONT ID="False">false</FONT>;
<FONT ID="LN">2039</FONT><A NAME="2039"></A>        }
<FONT ID="LN">2040</FONT><A NAME="2040"></A>        <FONT ID="If">if</FONT> (labelToPC.containsKey(endLabel)) {
<FONT ID="LN">2041</FONT><A NAME="2041"></A>            endPC = labelToPC.get(endLabel);
<FONT ID="LN">2042</FONT><A NAME="2042"></A>        } <FONT ID="Else">else</FONT> {
<FONT ID="LN">2043</FONT><A NAME="2043"></A>            endPC = <FONT ID="IntegerLiteral">0</FONT>;
<FONT ID="LN">2044</FONT><A NAME="2044"></A>            allLabelsResolved = <FONT ID="False">false</FONT>;
<FONT ID="LN">2045</FONT><A NAME="2045"></A>        }
<FONT ID="LN">2046</FONT><A NAME="2046"></A>        <FONT ID="If">if</FONT> (labelToPC.containsKey(handlerLabel)) {
<FONT ID="LN">2047</FONT><A NAME="2047"></A>            handlerPC = labelToPC.get(handlerLabel);
<FONT ID="LN">2048</FONT><A NAME="2048"></A>        } <FONT ID="Else">else</FONT> {
<FONT ID="LN">2049</FONT><A NAME="2049"></A>            handlerPC = <FONT ID="IntegerLiteral">0</FONT>;
<FONT ID="LN">2050</FONT><A NAME="2050"></A>            allLabelsResolved = <FONT ID="False">false</FONT>;
<FONT ID="LN">2051</FONT><A NAME="2051"></A>        }
<FONT ID="LN">2052</FONT><A NAME="2052"></A>        <FONT ID="Return">return</FONT> allLabelsResolved;
<FONT ID="LN">2053</FONT><A NAME="2053"></A>    }
<FONT ID="LN">2054</FONT><A NAME="2054"></A>
<FONT ID="LN">2055</FONT><A NAME="2055"></A>}
<FONT ID="LN">2056</FONT><A NAME="2056"></A>
<FONT ID="LN">2057</FONT><A NAME="2057"></A><FONT ID="FormalComment">/**
<FONT ID="LN">2058</FONT><A NAME="2058"></A> * Instances of this class form the elements of the CLBranchStack which is used
<FONT ID="LN">2059</FONT><A NAME="2059"></A> * for control flow analysis to compute maximum depth of operand stack for a
<FONT ID="LN">2060</FONT><A NAME="2060"></A> * method.
<FONT ID="LN">2061</FONT><A NAME="2061"></A> */</FONT>
<FONT ID="LN">2062</FONT><A NAME="2062"></A>
<FONT ID="LN">2063</FONT><A NAME="2063"></A><FONT ID="Class">class</FONT> CLBranchTarget {
<FONT ID="LN">2064</FONT><A NAME="2064"></A>
<FONT ID="LN">2065</FONT><A NAME="2065"></A>    <FONT ID="FormalComment">/** Target instruction. */</FONT>
<FONT ID="LN">2066</FONT><A NAME="2066"></A>    <FONT ID="Public">public</FONT> <A HREF="../jminusminus/CLInstruction.java.html">CLInstruction</A> target;
<FONT ID="LN">2067</FONT><A NAME="2067"></A>
<FONT ID="LN">2068</FONT><A NAME="2068"></A>    <FONT ID="FormalComment">/** Depth of stack before the target instruction is executed. */</FONT>
<FONT ID="LN">2069</FONT><A NAME="2069"></A>    <FONT ID="Public">public</FONT> <FONT ID="Int">int</FONT> stackDepth;
<FONT ID="LN">2070</FONT><A NAME="2070"></A>
<FONT ID="LN">2071</FONT><A NAME="2071"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">2072</FONT><A NAME="2072"></A>     * Construct a CLBranchTarget object.
<FONT ID="LN">2073</FONT><A NAME="2073"></A>     * 
<FONT ID="LN">2074</FONT><A NAME="2074"></A>     * @param target
<FONT ID="LN">2075</FONT><A NAME="2075"></A>     *            the target instruction.
<FONT ID="LN">2076</FONT><A NAME="2076"></A>     * @param stackDepth
<FONT ID="LN">2077</FONT><A NAME="2077"></A>     *            depth of stack before the target instruction is executed.
<FONT ID="LN">2078</FONT><A NAME="2078"></A>     */</FONT>
<FONT ID="LN">2079</FONT><A NAME="2079"></A>
<FONT ID="LN">2080</FONT><A NAME="2080"></A>    <FONT ID="Public">public</FONT> CLBranchTarget(<A HREF="../jminusminus/CLInstruction.java.html">CLInstruction</A> target, <FONT ID="Int">int</FONT> stackDepth) {
<FONT ID="LN">2081</FONT><A NAME="2081"></A>        <FONT ID="This">this</FONT>.target = target;
<FONT ID="LN">2082</FONT><A NAME="2082"></A>        <FONT ID="This">this</FONT>.stackDepth = stackDepth;
<FONT ID="LN">2083</FONT><A NAME="2083"></A>    }
<FONT ID="LN">2084</FONT><A NAME="2084"></A>
<FONT ID="LN">2085</FONT><A NAME="2085"></A>}
<FONT ID="LN">2086</FONT><A NAME="2086"></A>
<FONT ID="LN">2087</FONT><A NAME="2087"></A><FONT ID="FormalComment">/**
<FONT ID="LN">2088</FONT><A NAME="2088"></A> * This class is used for control flow analysis to compute maximum depth of
<FONT ID="LN">2089</FONT><A NAME="2089"></A> * operand stack for a method.
<FONT ID="LN">2090</FONT><A NAME="2090"></A> */</FONT>
<FONT ID="LN">2091</FONT><A NAME="2091"></A>
<FONT ID="LN">2092</FONT><A NAME="2092"></A><FONT ID="Class">class</FONT> CLBranchStack {
<FONT ID="LN">2093</FONT><A NAME="2093"></A>
<FONT ID="LN">2094</FONT><A NAME="2094"></A>    <FONT ID="FormalComment">/** Branch targets yet to visit. */</FONT>
<FONT ID="LN">2095</FONT><A NAME="2095"></A>    <FONT ID="Private">private</FONT> Stack&lt;CLBranchTarget&gt; branchTargets;
<FONT ID="LN">2096</FONT><A NAME="2096"></A>
<FONT ID="LN">2097</FONT><A NAME="2097"></A>    <FONT ID="FormalComment">/** Branch targets already visited. */</FONT>
<FONT ID="LN">2098</FONT><A NAME="2098"></A>    <FONT ID="Private">private</FONT> Hashtable&lt;<A HREF="../jminusminus/CLInstruction.java.html">CLInstruction</A>, CLBranchTarget&gt; visitedTargets;
<FONT ID="LN">2099</FONT><A NAME="2099"></A>
<FONT ID="LN">2100</FONT><A NAME="2100"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">2101</FONT><A NAME="2101"></A>     * Return an instance of CLBranchTarget with the specified information and
<FONT ID="LN">2102</FONT><A NAME="2102"></A>     * record the target as visited.
<FONT ID="LN">2103</FONT><A NAME="2103"></A>     * 
<FONT ID="LN">2104</FONT><A NAME="2104"></A>     * @param target
<FONT ID="LN">2105</FONT><A NAME="2105"></A>     *            the target instruction.
<FONT ID="LN">2106</FONT><A NAME="2106"></A>     * @param stackDepth
<FONT ID="LN">2107</FONT><A NAME="2107"></A>     *            depth of stack before the target instruction is executed.
<FONT ID="LN">2108</FONT><A NAME="2108"></A>     * @return an instance of CLBranchTarget.
<FONT ID="LN">2109</FONT><A NAME="2109"></A>     */</FONT>
<FONT ID="LN">2110</FONT><A NAME="2110"></A>
<FONT ID="LN">2111</FONT><A NAME="2111"></A>    <FONT ID="Private">private</FONT> CLBranchTarget visit(<A HREF="../jminusminus/CLInstruction.java.html">CLInstruction</A> target, <FONT ID="Int">int</FONT> stackDepth) {
<FONT ID="LN">2112</FONT><A NAME="2112"></A>        CLBranchTarget bt = <FONT ID="New">new</FONT> CLBranchTarget(target, stackDepth);
<FONT ID="LN">2113</FONT><A NAME="2113"></A>        visitedTargets.put(target, bt);
<FONT ID="LN">2114</FONT><A NAME="2114"></A>        <FONT ID="Return">return</FONT> bt;
<FONT ID="LN">2115</FONT><A NAME="2115"></A>    }
<FONT ID="LN">2116</FONT><A NAME="2116"></A>
<FONT ID="LN">2117</FONT><A NAME="2117"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">2118</FONT><A NAME="2118"></A>     * Return true if the specified instruction has been visited, false
<FONT ID="LN">2119</FONT><A NAME="2119"></A>     * otherwise.
<FONT ID="LN">2120</FONT><A NAME="2120"></A>     * 
<FONT ID="LN">2121</FONT><A NAME="2121"></A>     * @param target
<FONT ID="LN">2122</FONT><A NAME="2122"></A>     *            the target instruction.
<FONT ID="LN">2123</FONT><A NAME="2123"></A>     * @return true if the specified instruction has been visited, false
<FONT ID="LN">2124</FONT><A NAME="2124"></A>     *         otherwise.
<FONT ID="LN">2125</FONT><A NAME="2125"></A>     */</FONT>
<FONT ID="LN">2126</FONT><A NAME="2126"></A>
<FONT ID="LN">2127</FONT><A NAME="2127"></A>    <FONT ID="Private">private</FONT> <FONT ID="Boolean">boolean</FONT> visited(<A HREF="../jminusminus/CLInstruction.java.html">CLInstruction</A> target) {
<FONT ID="LN">2128</FONT><A NAME="2128"></A>        <FONT ID="Return">return</FONT> (visitedTargets.get(target) != <FONT ID="Null">null</FONT>);
<FONT ID="LN">2129</FONT><A NAME="2129"></A>    }
<FONT ID="LN">2130</FONT><A NAME="2130"></A>
<FONT ID="LN">2131</FONT><A NAME="2131"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">2132</FONT><A NAME="2132"></A>     * Construct a CLBranchStack object.
<FONT ID="LN">2133</FONT><A NAME="2133"></A>     */</FONT>
<FONT ID="LN">2134</FONT><A NAME="2134"></A>
<FONT ID="LN">2135</FONT><A NAME="2135"></A>    <FONT ID="Public">public</FONT> CLBranchStack() {
<FONT ID="LN">2136</FONT><A NAME="2136"></A>        <FONT ID="This">this</FONT>.branchTargets = <FONT ID="New">new</FONT> Stack&lt;CLBranchTarget&gt;();
<FONT ID="LN">2137</FONT><A NAME="2137"></A>        <FONT ID="This">this</FONT>.visitedTargets = <FONT ID="New">new</FONT> Hashtable&lt;<A HREF="../jminusminus/CLInstruction.java.html">CLInstruction</A>, CLBranchTarget&gt;();
<FONT ID="LN">2138</FONT><A NAME="2138"></A>    }
<FONT ID="LN">2139</FONT><A NAME="2139"></A>
<FONT ID="LN">2140</FONT><A NAME="2140"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">2141</FONT><A NAME="2141"></A>     * Push the specified information into the stack as a CLBranchTarget
<FONT ID="LN">2142</FONT><A NAME="2142"></A>     * instance if the target has not been visited yet.
<FONT ID="LN">2143</FONT><A NAME="2143"></A>     * 
<FONT ID="LN">2144</FONT><A NAME="2144"></A>     * @param target
<FONT ID="LN">2145</FONT><A NAME="2145"></A>     *            the target instruction.
<FONT ID="LN">2146</FONT><A NAME="2146"></A>     * @param stackDepth
<FONT ID="LN">2147</FONT><A NAME="2147"></A>     *            depth of stack before the target instruction is executed.
<FONT ID="LN">2148</FONT><A NAME="2148"></A>     */</FONT>
<FONT ID="LN">2149</FONT><A NAME="2149"></A>
<FONT ID="LN">2150</FONT><A NAME="2150"></A>    <FONT ID="Public">public</FONT> <FONT ID="Void">void</FONT> push(<A HREF="../jminusminus/CLInstruction.java.html">CLInstruction</A> target, <FONT ID="Int">int</FONT> stackDepth) {
<FONT ID="LN">2151</FONT><A NAME="2151"></A>        <FONT ID="If">if</FONT> (visited(target)) {
<FONT ID="LN">2152</FONT><A NAME="2152"></A>            <FONT ID="Return">return</FONT>;
<FONT ID="LN">2153</FONT><A NAME="2153"></A>        }
<FONT ID="LN">2154</FONT><A NAME="2154"></A>        branchTargets.push(visit(target, stackDepth));
<FONT ID="LN">2155</FONT><A NAME="2155"></A>    }
<FONT ID="LN">2156</FONT><A NAME="2156"></A>
<FONT ID="LN">2157</FONT><A NAME="2157"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">2158</FONT><A NAME="2158"></A>     * Pop and return an element from the stack. null is returned if the stack
<FONT ID="LN">2159</FONT><A NAME="2159"></A>     * is empty.
<FONT ID="LN">2160</FONT><A NAME="2160"></A>     * 
<FONT ID="LN">2161</FONT><A NAME="2161"></A>     * @return an element from the stack.
<FONT ID="LN">2162</FONT><A NAME="2162"></A>     */</FONT>
<FONT ID="LN">2163</FONT><A NAME="2163"></A>
<FONT ID="LN">2164</FONT><A NAME="2164"></A>    <FONT ID="Public">public</FONT> CLBranchTarget pop() {
<FONT ID="LN">2165</FONT><A NAME="2165"></A>        <FONT ID="If">if</FONT> (!branchTargets.empty()) {
<FONT ID="LN">2166</FONT><A NAME="2166"></A>            CLBranchTarget bt = (CLBranchTarget) branchTargets.pop();
<FONT ID="LN">2167</FONT><A NAME="2167"></A>            <FONT ID="Return">return</FONT> bt;
<FONT ID="LN">2168</FONT><A NAME="2168"></A>        }
<FONT ID="LN">2169</FONT><A NAME="2169"></A>        <FONT ID="Return">return</FONT> <FONT ID="Null">null</FONT>;
<FONT ID="LN">2170</FONT><A NAME="2170"></A>    }
<FONT ID="LN">2171</FONT><A NAME="2171"></A>
<FONT ID="LN">2172</FONT><A NAME="2172"></A>}
<FONT ID="LN">2173</FONT><A NAME="2173"></A>
<FONT ID="LN">2174</FONT><A NAME="2174"></A><FONT ID="FormalComment">/**
<FONT ID="LN">2175</FONT><A NAME="2175"></A> * A class loader to be able to load a class from a byte stream.
<FONT ID="LN">2176</FONT><A NAME="2176"></A> */</FONT>
<FONT ID="LN">2177</FONT><A NAME="2177"></A>
<FONT ID="LN">2178</FONT><A NAME="2178"></A><FONT ID="Class">class</FONT> ByteClassLoader <FONT ID="Extends">extends</FONT> ClassLoader {
<FONT ID="LN">2179</FONT><A NAME="2179"></A>
<FONT ID="LN">2180</FONT><A NAME="2180"></A>    <FONT ID="FormalComment">/** Bytes representing the class. */</FONT>
<FONT ID="LN">2181</FONT><A NAME="2181"></A>    <FONT ID="Private">private</FONT> <FONT ID="Byte">byte</FONT>[] bytes;
<FONT ID="LN">2182</FONT><A NAME="2182"></A>
<FONT ID="LN">2183</FONT><A NAME="2183"></A>    <FONT ID="FormalComment">/** Has a package been defined for this class loader? */</FONT>
<FONT ID="LN">2184</FONT><A NAME="2184"></A>    <FONT ID="Private">private</FONT> <FONT ID="Boolean">boolean</FONT> pkgDefined = <FONT ID="False">false</FONT>;
<FONT ID="LN">2185</FONT><A NAME="2185"></A>
<FONT ID="LN">2186</FONT><A NAME="2186"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">2187</FONT><A NAME="2187"></A>     * Set the bytes representing the class.
<FONT ID="LN">2188</FONT><A NAME="2188"></A>     * 
<FONT ID="LN">2189</FONT><A NAME="2189"></A>     * @param bytes
<FONT ID="LN">2190</FONT><A NAME="2190"></A>     *            bytes representing the class.
<FONT ID="LN">2191</FONT><A NAME="2191"></A>     */</FONT>
<FONT ID="LN">2192</FONT><A NAME="2192"></A>
<FONT ID="LN">2193</FONT><A NAME="2193"></A>    <FONT ID="Public">public</FONT> <FONT ID="Void">void</FONT> setClassBytes(<FONT ID="Byte">byte</FONT>[] bytes) {
<FONT ID="LN">2194</FONT><A NAME="2194"></A>        <FONT ID="This">this</FONT>.bytes = bytes;
<FONT ID="LN">2195</FONT><A NAME="2195"></A>    }
<FONT ID="LN">2196</FONT><A NAME="2196"></A>
<FONT ID="LN">2197</FONT><A NAME="2197"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">2198</FONT><A NAME="2198"></A>     * @inheritDoc
<FONT ID="LN">2199</FONT><A NAME="2199"></A>     */</FONT>
<FONT ID="LN">2200</FONT><A NAME="2200"></A>
<FONT ID="LN">2201</FONT><A NAME="2201"></A>    <FONT ID="Public">public</FONT> Class&lt;?&gt; loadClass(String name, <FONT ID="Boolean">boolean</FONT> resolve)
<FONT ID="LN">2202</FONT><A NAME="2202"></A>            <FONT ID="Throws">throws</FONT> ClassNotFoundException {
<FONT ID="LN">2203</FONT><A NAME="2203"></A>        Class cls = findLoadedClass(name);
<FONT ID="LN">2204</FONT><A NAME="2204"></A>        <FONT ID="If">if</FONT> (cls == <FONT ID="Null">null</FONT>) {
<FONT ID="LN">2205</FONT><A NAME="2205"></A>            <FONT ID="Try">try</FONT> {
<FONT ID="LN">2206</FONT><A NAME="2206"></A>                cls = findSystemClass(name);
<FONT ID="LN">2207</FONT><A NAME="2207"></A>            } <FONT ID="Catch">catch</FONT> (Exception e) {
<FONT ID="LN">2208</FONT><A NAME="2208"></A>                <FONT ID="SingleLineComment">// Ignore these
<FONT ID="LN">2209</FONT><A NAME="2209"></A></FONT>            }
<FONT ID="LN">2210</FONT><A NAME="2210"></A>        }
<FONT ID="LN">2211</FONT><A NAME="2211"></A>        <FONT ID="If">if</FONT> (cls == <FONT ID="Null">null</FONT>) {
<FONT ID="LN">2212</FONT><A NAME="2212"></A>            name = name.replace(<FONT ID="StringLiteral">"/"</FONT>, <FONT ID="StringLiteral">"."</FONT>);
<FONT ID="LN">2213</FONT><A NAME="2213"></A>            String pkg = name.lastIndexOf(<FONT ID="CharacerLiteral">'.'</FONT>) == -<FONT ID="IntegerLiteral">1</FONT> ? <FONT ID="StringLiteral">""</FONT> : name.substring(<FONT ID="IntegerLiteral">0</FONT>,
<FONT ID="LN">2214</FONT><A NAME="2214"></A>                    name.lastIndexOf(<FONT ID="CharacerLiteral">'.'</FONT>));
<FONT ID="LN">2215</FONT><A NAME="2215"></A>            <FONT ID="If">if</FONT> (!pkgDefined) {
<FONT ID="LN">2216</FONT><A NAME="2216"></A>                <FONT ID="SingleLineComment">// Packages must be created before the class is
<FONT ID="LN">2217</FONT><A NAME="2217"></A></FONT>                <FONT ID="SingleLineComment">// defined, and package names must be unique
<FONT ID="LN">2218</FONT><A NAME="2218"></A></FONT>                <FONT ID="SingleLineComment">// within
<FONT ID="LN">2219</FONT><A NAME="2219"></A></FONT>                <FONT ID="SingleLineComment">// a class loader and cannot be redefined or
<FONT ID="LN">2220</FONT><A NAME="2220"></A></FONT>                <FONT ID="SingleLineComment">// changed once created
<FONT ID="LN">2221</FONT><A NAME="2221"></A></FONT>                definePackage(pkg, <FONT ID="StringLiteral">""</FONT>, <FONT ID="StringLiteral">""</FONT>, <FONT ID="StringLiteral">""</FONT>, <FONT ID="StringLiteral">""</FONT>, <FONT ID="StringLiteral">""</FONT>, <FONT ID="StringLiteral">""</FONT>, <FONT ID="Null">null</FONT>);
<FONT ID="LN">2222</FONT><A NAME="2222"></A>                pkgDefined = <FONT ID="True">true</FONT>;
<FONT ID="LN">2223</FONT><A NAME="2223"></A>            }
<FONT ID="LN">2224</FONT><A NAME="2224"></A>            cls = defineClass(name, bytes, <FONT ID="IntegerLiteral">0</FONT>, bytes.length);
<FONT ID="LN">2225</FONT><A NAME="2225"></A>            <FONT ID="If">if</FONT> (resolve &amp;&amp; cls != <FONT ID="Null">null</FONT>) {
<FONT ID="LN">2226</FONT><A NAME="2226"></A>                resolveClass(cls);
<FONT ID="LN">2227</FONT><A NAME="2227"></A>            }
<FONT ID="LN">2228</FONT><A NAME="2228"></A>        }
<FONT ID="LN">2229</FONT><A NAME="2229"></A>        <FONT ID="Return">return</FONT> cls;
<FONT ID="LN">2230</FONT><A NAME="2230"></A>    }
<FONT ID="LN">2231</FONT><A NAME="2231"></A>
<FONT ID="LN">2232</FONT><A NAME="2232"></A>}
<FONT ID="LN">2233</FONT><A NAME="2233"></A>
<FONT ID="LN">2234</FONT><A NAME="2234"></A><FONT ID="FormalComment">/**
<FONT ID="LN">2235</FONT><A NAME="2235"></A> * Inherits from java.out.DataOutputStream and provides an extra function for
<FONT ID="LN">2236</FONT><A NAME="2236"></A> * writing unsigned int to the output stream, which is required for writing Java
<FONT ID="LN">2237</FONT><A NAME="2237"></A> * class files.
<FONT ID="LN">2238</FONT><A NAME="2238"></A> */</FONT>
<FONT ID="LN">2239</FONT><A NAME="2239"></A>
<FONT ID="LN">2240</FONT><A NAME="2240"></A><FONT ID="Class">class</FONT> CLOutputStream <FONT ID="Extends">extends</FONT> DataOutputStream {
<FONT ID="LN">2241</FONT><A NAME="2241"></A>
<FONT ID="LN">2242</FONT><A NAME="2242"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">2243</FONT><A NAME="2243"></A>     * Construct a CLOutputStream from the specified output stream.
<FONT ID="LN">2244</FONT><A NAME="2244"></A>     * 
<FONT ID="LN">2245</FONT><A NAME="2245"></A>     * @param out
<FONT ID="LN">2246</FONT><A NAME="2246"></A>     *            output stream.
<FONT ID="LN">2247</FONT><A NAME="2247"></A>     */</FONT>
<FONT ID="LN">2248</FONT><A NAME="2248"></A>
<FONT ID="LN">2249</FONT><A NAME="2249"></A>    <FONT ID="Public">public</FONT> CLOutputStream(OutputStream out) {
<FONT ID="LN">2250</FONT><A NAME="2250"></A>        <FONT ID="Super">super</FONT>(out);
<FONT ID="LN">2251</FONT><A NAME="2251"></A>    }
<FONT ID="LN">2252</FONT><A NAME="2252"></A>
<FONT ID="LN">2253</FONT><A NAME="2253"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">2254</FONT><A NAME="2254"></A>     * Write four bytes to the output stream to represent the value of the
<FONT ID="LN">2255</FONT><A NAME="2255"></A>     * argument. The byte values to be written, in the order shown, are:
<FONT ID="LN">2256</FONT><A NAME="2256"></A>     * 
<FONT ID="LN">2257</FONT><A NAME="2257"></A>     * &lt;pre&gt;
<FONT ID="LN">2258</FONT><A NAME="2258"></A>     *     (byte) ( 0xFF &amp;amp; ( v &amp;gt;&amp;gt; 24 ) )
<FONT ID="LN">2259</FONT><A NAME="2259"></A>     *     (byte) ( 0xFF &amp;amp; ( v &amp;gt;&amp;gt; 16 ) )
<FONT ID="LN">2260</FONT><A NAME="2260"></A>     *     (byte) ( 0xFF &amp;amp; ( v &amp;gt;&amp;gt; 8 ) )
<FONT ID="LN">2261</FONT><A NAME="2261"></A>     *     (byte) ( 0xFF &amp;amp; v )
<FONT ID="LN">2262</FONT><A NAME="2262"></A>     * &lt;/pre&gt;
<FONT ID="LN">2263</FONT><A NAME="2263"></A>     * 
<FONT ID="LN">2264</FONT><A NAME="2264"></A>     * @param v
<FONT ID="LN">2265</FONT><A NAME="2265"></A>     *            the int value to be written.
<FONT ID="LN">2266</FONT><A NAME="2266"></A>     * @throws IOException
<FONT ID="LN">2267</FONT><A NAME="2267"></A>     *             if an error occurs while writing.
<FONT ID="LN">2268</FONT><A NAME="2268"></A>     */</FONT>
<FONT ID="LN">2269</FONT><A NAME="2269"></A>
<FONT ID="LN">2270</FONT><A NAME="2270"></A>    <FONT ID="Public">public</FONT> <FONT ID="Final">final</FONT> <FONT ID="Void">void</FONT> writeInt(<FONT ID="Long">long</FONT> v) <FONT ID="Throws">throws</FONT> IOException {
<FONT ID="LN">2271</FONT><A NAME="2271"></A>        <FONT ID="Long">long</FONT> mask = <FONT ID="IntegerLiteral">0xFF</FONT>;
<FONT ID="LN">2272</FONT><A NAME="2272"></A>        out.write((<FONT ID="Byte">byte</FONT>) (mask &amp; (v &gt;&gt; <FONT ID="IntegerLiteral">24</FONT>)));
<FONT ID="LN">2273</FONT><A NAME="2273"></A>        out.write((<FONT ID="Byte">byte</FONT>) (mask &amp; (v &gt;&gt; <FONT ID="IntegerLiteral">16</FONT>)));
<FONT ID="LN">2274</FONT><A NAME="2274"></A>        out.write((<FONT ID="Byte">byte</FONT>) (mask &amp; (v &gt;&gt; <FONT ID="IntegerLiteral">8</FONT>)));
<FONT ID="LN">2275</FONT><A NAME="2275"></A>        out.write((<FONT ID="Byte">byte</FONT>) (mask &amp; v));
<FONT ID="LN">2276</FONT><A NAME="2276"></A>    }
<FONT ID="LN">2277</FONT><A NAME="2277"></A>
<FONT ID="LN">2278</FONT><A NAME="2278"></A>}
<FONT ID="LN">2279</FONT><A NAME="2279"></A></pre>
</BODY>
</HTML>